1
votes

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 ?

1
From your code, it seems you are using adal.net instead of adal.js to get a token for graph? Is your app backend talking to graph?ezile

1 Answers

1
votes

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