How do I get Bearer (Access) Token in v2 format using @azure/msal-react?
See original GitHub issueCore Library
MSAL.js v2 (@azure/msal-browser)
Core Library Version
2.14.2
Wrapper Library
MSAL React (@azure/msal-react)
Wrapper Library Version
1.0.0
Description
I created a new app service and set accessTokenAcceptedVersion to 2 in manifest.json as I am looking for a v2 token similar to here. However the accessToken generated by Microsoft always has an iss value of sts.windows.net when decoded. I would like it to be login.microsoftonline.com. Please advice.
This is my implementation:
This is my token when decoded:
Please advice.
MSAL Configuration
No response
Relevant Code Snippets
let token;
msalInstance.acquireTokenSilent({
...loginRequest
}).then((accessTokenResponse) => {
// Acquire token silent success
token = accessTokenResponse.accessToken;
})
Identity Provider
Azure AD / MSA
Source
External (Customer)
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Single-page application: Acquire a token to call an API
When this method is called, the library first checks the cache in browser storage to see if a non-expired access token exists and...
Read more >Generating and using app-only Bearer Tokens | Docs
A Bearer Token is a byte array of unspecified format that you generate using ... Our Bearer Token used to authenticate to resources...
Read more >Msal Get Access Token
Acquiring and Using an Access Token. Acquire a token from the cache (MSAL. How do I get Bearer (Access) Token in v2 format...
Read more >draft-ietf-oauth-v2-bearer-23
The OAuth 2.0 Authorization Framework: Bearer Token Usage (Internet-Draft, 2018) ... While designed for use with access tokens resulting from OAuth 2.0 ......
Read more >azure msal
JS v2 in a Single Page Application (SPA) to get an access token for the web API ... Loop with Angular Application and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@a2441918 cheers! Closing this. Let us know if you need further help.
@a2441918 every access token is meant for a resource, represented in the
aud
claim. To get a token for your backend API, you need to use the scope(s) that you expose in your access token request. Check out the docs for more on this.And yes, it is best practice to create separate app registrations for your client and service apps. From the screenshots, the scopes you exposed doesn’t look right. Please check out this tutorial, which shows how do this properly.