-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get access token for API? #20
Comments
I suppose you need to use
Otherwise, an API should have published scopes identified by URLs and an app should be granted some of these scopes in AD settings. Then you specify needed scope(s) in the scopes parameter.
Hope this helps. |
This did the trick. I got a token with this call:
Thank you very much! Now I'm in a weird spot where I want to be able to call MS Graph AND my API. But during the acquireToken method, it sets the msal object's accessToken to whatever is returned. I find that sometimes the calls' timing is weird and they won't be set as expected during the proper calls (e.g. an API call will happen after the Graph call and have the wrong token). Is there a way to store multiple tokens and use the appropriate one per request? |
Sorry, cannot help you further :( As I see from the code, vue-msal only stores one "current" access token which is used for MS Graph calls. Probably, you'll be able to use several instances of vue-msal in the same app for working with different APIs/scopes. |
No worries, I understand. I actually wound up implementing MSAL myself to have easier access to the MSAL methods. This project helped me understand it a lot better, though! |
Apologies if this doesn't fit here, but I'm having a hell of a time figuring out how to use this to get a token to call an API. The API is hosted in the same Azure AD tenant as my web app that's using vue-msal. I've been able to authenticate properly but the token audience always comes back as the GUID for MS Graph (00000003-0000-0000-c000-000000000000). All the other info in the token seems correct, but when I pass the access_token as a bearer token to the API, I get a 401 Unauthorized response.
Here's the config I'm using.
I'm very inexperienced at auth in general, so I may even be asking the wrong questions. Anyone able to steer me in the right direction here?
The text was updated successfully, but these errors were encountered: