No 'Access-Control-Allow-Origin' header with Microsoft Online Auth

后端 未结 2 644
梦如初夏
梦如初夏 2020-11-27 08:07

I am trying to make a simple request to get an access token using the Microsoft graph OAuth endpoint. When I send the simple request below I get

No \

2条回答
  •  有刺的猬
    2020-11-27 08:37

    To integrate AAD in javascript, we suggest you to use azure-activedirectory-library-for-js which is a library in javascript for frontend to integrate AAD with a ease.

    There are 2 options we need to pay attention on before we use ADAL for JS:

    • According the node at https://github.com/OfficeDev/O365-jQuery-CORS#step-6--run-the-sample:

      Note This sample will not work in Internet Explorer. Please use a different browser, such as Google Chrome. ADAL.js uses an iframe to get CORS API tokens for resources other than the SPA's own backend. These iframe requests require access to the browser's cookies to authenticate with Azure Active Directory. Unfortunately, cookies are not accessible to Internet Explorer when the app is running in localhost.

    • Enable the oauth2AllowImplicitFlow of your Azure AD application. Refer to https://crmdynamicsblog.wordpress.com/2016/03/17/response-type-token-is-not-enabled-for-the-application-2/ for the detailed steps.

    Here is the code sample to acquire access token from Microsoft Graph:

    
    
    
    login
    access token
    
    
    

提交回复
热议问题