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.

login.live.com CORS error

See original GitHub issue

Core Library

MSAL.js v2 (@azure/msal-browser)

Core Library Version

^2.19.0

Wrapper Library

Not Applicable

Wrapper Library Version

None

Description

I need to retrieve a token with scope “OneDrive.ReadWrite” for use with a file picker targeting OneDrive consumer (@live.com account). I setup the configuration as below and pass the scopes. As best I can tell from various available documents this should work. But I am currently stuck on a CORS error hitting “https://login.live.com/.well-known/openid-configuration” from localhost. I can hit that url directly so the url is correct.

My app has the correct redirects configured, is setup as a SPA, and works for all other cases (SharePoint, Graph).

For reference I reviewed this issue, associated PR, and the docs it updated.

Appreciate any guidance to the proper way to achieve getting a token from login.live.com.

MSAL Configuration

{
    auth: {
        authority: "https://login.live.com/",
        clientId,
        knownAuthorities: ["login.live.com"],
        protocolMode: "OIDC",
        redirectUri: "http://localhost:3000",
    },
}

Relevant Code Snippets

import { Configuration, PublicClientApplication } from "@azure/msal-browser";

 const app = new PublicClientApplication(config);

let accessToken: string;
                const authParams = { scopes: scopes || [`${combine(command.resource, ".default")}`] };

                try {

                    // see if we have already the idtoken saved
                    const resp = await app.acquireTokenSilent(authParams);
                    accessToken = resp.accessToken;

                } catch (e) {

                    // per examples we fall back to popup
                    const resp = await app.loginPopup(authParams);

                    if (resp.account) {
                        app.setActiveAccount(resp.account);
                    }

                    if (resp.idToken) {

                        const resp2 = await app.acquireTokenSilent(authParams);
                        accessToken = resp2.accessToken;

                    } else {

                        this.error(e);
                    }
                }

                if (accessToken) {
                    this.log(`Returning token for auth type: '${command.type}'`, 0);
                    result = {
                        result: "token",
                        token: accessToken,
                    }
                }

Identity Provider

Other

Source

Internal (Microsoft)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
hectormmgcommented, Feb 16, 2022

@patrick-rodgers thanks for raising the issue, I’ve gone through your description and the issues/PRs/docs you link to and haven’t seen an obvious answer here. I’ll look into it and get back to you soon.

0reactions
patrick-rodgerscommented, Feb 28, 2022

Hmm, I got the below error, guessing this choice isn’t in the UI due to some conditions in the back end - switching probably isn’t supported. All good. I am going to create a new registration to test. Thanks for your help!

Failed to update PickerTestingApp application. Error detail: Property accessTokenAcceptedVersion is invalid. [BjnAFCjLYGl0+Sr0bFlWBc]
Read more comments on GitHub >

github_iconTop Results From Across the Web

OneDrive oAuth token request gets CORS error - Stack Overflow
The code is successfully retrieved by the application, but when a call is made to https://login.live.com/oauth20_token.srf the request fails ...
Read more >
Getting CORS error when bachend application send refresh ...
Just wondering, if this CORS error is coming because Azure(login.microsoftonline.com) is blocking out organization domain, and they need to ...
Read more >
CORS errors and how to solve them - Topcoder
Or, your API fails and shows a CORS error in the console. ... Let's say you log in to facebook.com and your browser...
Read more >
Update to Craft 4 causing CORS error on login to CP on live ...
The error suggests that your config is using www..com as your primary site URL, yet the error suggests that you've logged in at...
Read more >
CORS errors - HTTP - MDN Web Docs - Mozilla
If the CORS configuration isn't setup correctly, the browser console will present an error like "Cross-Origin Request Blocked: The Same ...
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