简体   繁体   中英

Azure AD Graph API Bearer Token with ADAL JS

As Learning application , i am using AngularJS,ADAL js and WebAPI as Mentioned in this post.

Angularjs-authentication-using-azure-active-directory-authentication-library-adal

Tutorial is very neat and clean for the implementation. After the authentication i am trying to add a User in the Azure AD[ The same AD i validated my credentials against ].

To work with Azure AD there is Azure AD Graph API.which requires a Bearer Token.

To get The Bearer token AuthorizationContext will be used.

var authcontext = new AuthenticationContext(GraphRequest.authority);

AuthenticationResult authResult = authcontext.AcquireToken(GraphRequest.apiResourceId, 
GraphRequest.clientId, GraphRequest.redirectUri);

As Authentication context is in control , so it is asking again credentials with popup. but i already have a claimPrincipal.

Is there any way i can use ClaimPrincipal to get the bearerToken ?

Have you had a chance to take a look at our public samples on GitHub? Something like this might be useful for you to look at: https://github.com/Azure-Samples/active-directory-angularjs-singlepageapp-dotnet-webapi

Otherwise, in general, you cannot take an ID Token and then use it to upgrade to an access token. What you can do instead is skip that login prompt, and just do the code you pasted above which obtains an access token, which can be turned into an ID token.

I hope this makes sense, please feel free to reach out with any further questions. Shawn Tabrizi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM