CORS issue while accesing and getting token for the application on application level and not logged in user?

Dev 111 Reputation points
2021-04-06T13:30:51.287+00:00

I want to access organization user on the application level for users which are not logged in.
Below is the API I am hitting for same

https://login.microsoftonline.com/xxxxxxxxxxxxxxxxxxxxxxxx/oauth2/v2.0/token

I am getting the CORS error although i am allowing CORS
in the header.
Please find sample to access the token.

const requestHeaders: HeadersInit = new Headers();
requestHeaders.set('Content-Type', 'application/x-www-form-urlencoded');
requestHeaders.set('client_id','xxxxxxxxxxxxxxxxxxxxxxxx');
requestHeaders.set('scope',"https://graph.microsoft.com/.default");
requestHeaders.set('Access-Control-Allow-Origin',"*");
requestHeaders.set('client_secret','xxxxxxxxxxxxxxxxxxx');
requestHeaders.set('grant_type',"client_credentials");

Thanks
Sanjeev

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,760 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Danstan Onyango 3,741 Reputation points Microsoft Employee
    2021-04-13T17:07:07.777+00:00

    I see this question same as this one you asked and I answered. Please check the linked question.

    0 comments No comments