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.

Making multiple calls to acquireTokenSilent, may result in multiple requests to service POST /token, is there a way to use whichever request succeeded?

See original GitHub issue

Library

  • msal@1.x.x or @azure/msal@1.x.x
  • @azure/msal-browser@2.6.1
  • @azure/msal-node@1.x.x
  • @azure/msal-react@1.x.x
  • @azure/msal-angular@0.x.x
  • @azure/msal-angular@1.x.x
  • @azure/msal-angular@2.x.x
  • @azure/msal-angularjs@1.x.x

Description

Currently in our app, we make a call to acquireTokenSilent before any api request. We can make api requests in parallel which result in parallel calls to acquireTokenSilent. When needed, acquireTokenSilent will make network calls to POST /token to get a new token. Currently this results in multiple calls to POST /token.

In some of our logs, we see that one or two of them will fail with status code 0: Failed to fetch.

  1. I’m not sure why status code 0 is happening for some requests, but other requests succeed
  2. In the same batch of parallel requests to POST /token, if only 1 fails, does the library return the result of any previously successful request?
  3. For example say request A and request B both start at the same time. Request A succeeds first, and then request B fails. Can the acquireTokenSilent method return the result of request A for both calls?

Source

  • Internal (Microsoft)
  • Customer request

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JWesscommented, Jun 3, 2021

I am very excited to hear this will be implemented. Hopefully soon!

2reactions
jo-arroyocommented, Jan 19, 2021

@thoo1 That’s a reasonable request and we will look into it.

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 >
Getting null everytime when AcquireTokenSilent in ASP.NET ...
My project is .ASP.Net 4.8. In order to fix the issue, I did not update the code, my code remain as is. I...
Read more >
angular msal refresh token | The AI Search Engine You Control
You could use acquireTokenSilent method to automatically refresh token for you in MSAL.NET. MSAL uses a cache to store tokens based on specific...
Read more >
Silent Refresh - Refreshing Access Tokens when using the ...
This also applies to any flow on a public client incapable of keeping a secret or making secure back channel requests. If a...
Read more >
Modern Authentication with Azure Active Directory for Web ...
Azure AD is a public cloud service, application developers can also take ... businesses, including the many that are already using Azure AD,...
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