question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get a V1 token using MSAL.js

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[X] Other... Please describe: General Help 

Library version

"@azure/msal-angular": "^0.1.2"

Current behavior

I end up getting a V2 token for an app that requires a V1 token

Expected behavior

I would be able to get a V1 token

Minimal reproduction of the problem with instructions

I have setup an angular project like so:

@NgModule({
	declarations: [AppComponent],
	imports: [
		...,
		MsalModule.forRoot({
			clientID: "{applicationGuid}",
			authority: "https://login.microsoftonline.com/{tenantGuid}/",
		}),
	]
})

Where the application Id is that of Azure Blockchain Workbench product. I have added my applications URLs to the list of Reply URLs for the ADD Application and I am able to get a Bearer token as expected. When I go to use this token with the Blockchain API I get a 401 unauthorized. The only meaningful difference I can see between the tokens is the issuer url and the version

v1 token: https://sts.windows.net/2c72df40-3a20-41cd-a628-424afba070a5/ v2 token: https://login.microsoftonline.com/2c72df40-3a20-41cd-a628-424afba070a5/v2.0

I have a Swagger UI setup that will correctly generate an access token using the same authority and client id which leads me to believe it is the token version that is the issue.

What can I do to fix this?

I have tried setting the consentScope to ["{applicationGuid}/.default"] but then I end up with a v1 token for Microsoft Graph.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jberlyncommented, May 28, 2020

@jasonnutter I’m sorry but this doesn’t solve the original issue.

The question I believe relates to whether it’s possible to get an AAD v1 token using MSAL, not the access tokens.

If you take a look at the sample tokens in this documentation (https://docs.microsoft.com/en-us/azure/active-directory/develop/access-tokens), you can see that the issuer URL is different. The original poster @Meberem also pointed this out.

I have done as instructed in your document and adjusted the accessTokenAcceptedVersion, but I’m still receiving a v1 ID token when using MSAL.

0reactions
jasonnuttercommented, Jun 2, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Single-page application: Acquire a token to call an API
The pattern for acquiring tokens for APIs with MSAL.js is to first attempt a silent token request by using the acquireTokenSilent method.
Read more >
Is it possible to obtain an Azure AD V1 token using MSAL?
Yes, it is possible to request an V1 access token from the V2 endpoint. The type of access token (v1 or v2) that...
Read more >
Microsoft Authentication Library for JavaScript (MSAL.js)
In MSAL, you can get access tokens for the APIs your app needs to call using the acquireTokenSilent method which makes a silent...
Read more >
@azure/msal-browser - npm
Microsoft Authentication Library for JavaScript (MSAL.js) 2.0 for ... If you have MSAL v1.x currently running in your application, ...
Read more >
Using MSAL Interceptor to Call APIs with User Access Token
Github: https://github.com/tamani-coding/angular- msal -interceptor-exampleSee Part 1: https://youtu.be/TkCKqeYjpv0(00:00): Intro and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found