0

I'm trying to use the AD services to authenticate from a react app and send the token to my .Net Core to use the [Authorize] attribute, but as I could figure, the token I get here is just for authenticating into the Graph API.

Is there any way to get a token to use as "auth" header to call my API ?

JS:

this.userAgentApplication = new UserAgentApplication(config.appId, null, null); 

var access_token = this.userAgentApplication.acquireTokenSilent(config.scopes);

Then i get the access_token and send to my backend as an "Authorization" header with the value "Bearer ${access_token}"

1 Answer 1

1

You have to specify that you want an access token for your API through config.scopes.

You can use e.g.

api-client-id-here/.default

Or instead of .default you can specify a scope you have defined on the API. You can specify multiple of them if you want multiple scopes.

Sign up to request clarification or add additional context in comments.

2 Comments

I was using MSAL on the React app, now I'm using ADAL and I could authenticate into mine API. The question now is how to retrieve some adittional claims from the AD. eg.: extensionAttribute6
You can get those from MS Graph API I think. It might also be possible with the claims customization option: learn.microsoft.com/en-us/azure/active-directory/develop/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.