Search code examples
azureazure-active-directoryazure-web-app-serviceaccess-tokenazure-ad-graph-api

How can I create a Azure Web Application to authenticate User and acquire its Access Token?


I want to create an Azure Web Application that can authenticate an external/internal (from any Organization) user upon opening the Web Application link through Azure AD Credentials and acquire its Access token in return.

I want to use that Access Token to programmatically create an application registration in User's tenant.


Solution

  • First, you need to register an application and set it as a multi-tenant application, then use the auth code flow to authenticate the user and obtain an access token.

    Next, you need to use the access token to call the MS graph api to create an application, because you are using the auth code flow to obtain the token, so you need to grant delegation permissions to the application.

    see: sample.