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.

MSAL tokens cause preflight requests

See original GitHub issue

Library

  • msal@1.x.x or @azure/msal@1.x.x
  • @azure/msal-browser@2.x.x
  • @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

When the authentication is done by MSAL (client side) the token is stored in the browser’ storage and not in a cookie. Making requests to 3rd party services like Microsoft Graph with Authorization header yields preflight (OPTIONS) requests that in no time can lead to bottleneck. Getting 1 people info (name + avatar) requires 4 requests. Getting 2 people info requests 8 requests - which are more that most browser limits (6 requests per domain).

Is there any way to use the MSAL but skip the preflight requests? (storing the token in a cookie for example)

Source

  • Internal (Microsoft)
  • Customer request

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
hrazmsftcommented, Mar 15, 2021

I see. Thank you!

0reactions
pkanher617commented, Mar 15, 2021

The Authorization header is not considered a “simple request header”, which is why you are seeing a pre-flight request. I would reach out to the Graph API support to see if there are other ways to avoid these preflight requests, such as sending the authorization information in the query string instead of a header. It’s possible that the browser may cache these preflight requests as well, so I would look into that as well. Unfortunately after retrieving the tokens, there is nothing we can do to stop these options requests. We are looking at making our /token requests simple requests today in order to remove the preflight requests from the token acquisition calls as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CORS error in localhost but the Bearer Token does show in ...
This error message ("Redirect is not allowed for a preflight request.") indicates that your resource is responding to the browser's preflight ( ...
Read more >
API request triggering CORS error when using MSAL in ...
My expectation was since authentication happens in client side and so it takes the token to API and since JWT enabled in server,...
Read more >
Understand and solve Azure Active Directory Application ...
Provides an understanding of CORS in Azure Active Directory Application Proxy, and how to identify and solve CORS issues.
Read more >
Chapter 4. Handling preflight requests - CORS in Action
Let's think about a preflight request in the context of the ATM example from chapter 3. Banks sometimes put their ATMs inside a...
Read more >
Creating a custom HttpInterceptor to handle 'withCredentials ...
Client HTTP requests often need to set a few common settings and you don't want ... calls causing cookies and auth headers to...
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