CORS Issue
See original GitHub issueLibrary
-
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
Trying to generate token from registered app to access another api. Permission is granted in active directory app registration. http://localhost:3001/ added to redirect URI under SPA but getting following error
“‘https://login.microsoftonline.com/xxxxxx/oauth2/v2.0/token’ from origin ‘http://localhost:3001’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource”
Source
const msal = require('@azure/msal-node');
const config = {
auth: {
clientId: "sdsdwewewew-b98c-4bd4-a3d7-c3da07753a52",
authority: "https://login.microsoftonline.com/xxxx.onmicrosoft.com",
clientSecret: "Uxpsdwwewewewewo_4HqFk",
redirectUri: "http://localhost:3001/"
},
system: {
piiLoggingEnabled: false,
logLevel: msal.LogLevel.Verbose,
},
cache: {
cacheLocation: "localStorage", // Needed to avoid "User login is required" error.
storeAuthStateInCookie: false // Recommended to avoid certain IE/Edge issues.
}
}
const authenticate = (): any => {
const cca = new msal.ConfidentialClientApplication(config);
const clientCredentialRequest = {
scopes: ["api://zsdsdsdsdsd/.default"],
};
cca.acquireTokenByClientCredential(clientCredentialRequest).then((response: any) => {
console.log("Response: ", response);
}).catch((error: any) => {
console.log(JSON.stringify(error));
});
}
export default authenticate;
- Internal (Microsoft)
- Customer request
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
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 >Understanding and Resolving CORS Error - Contentstack
CORS is implemented on the server-side; it cannot be reconfigured on the client-side. The CORS behavior, commonly termed as CORS error, is a...
Read more >3 Ways to Fix the CORS Error — and How the Access-Control ...
The error stems from a security mechanism that browsers implement called the same-origin policy. The same-origin policy fights one of the most ...
Read more >CORS errors and how to solve them - Topcoder
CORS is an abbreviation for Cross-Origin Response Sharing. ... Or, your API fails and shows a CORS error in the console.
Read more >What Is a CORS Error and How to Fix It (3 Ways) - Bannerbear
As a CORS error occurs when the external API server doesn't return the HTTP headers required by the CORS standard, you can add...
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 FreeTop 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
Top GitHub Comments
Absolutely! If there is nothing else can I close this issue?
@pkanher617 thanks, its clear now. Thanks for the help