Grant tenant admin consent to an application by programming/coding

Yan Fang 0 Reputation points Microsoft Employee
2025-04-24T09:22:14.0033333+00:00

Hello, I have many test tenants and my work needs to grant tenant admin consent to an application.

The current solution is manual, here are the current steps I take:
1.Open browser and access this link:
https://login.microsoftonline.com/{$TenantId}/oauth2/authorize?client_id={$AppId}&response_type=code&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient

2.A login window pops up, login with the tenant admin account.

3.A consent window pops up, click "Accept".

203839-new-app.png

My question is how to automate the process using programming approach to skip all interactive actions?

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,243 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.