web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

CORS error occurred during the token retrieval process from Power pages

(0) ShareShare
ReportReport
Posted on by 700
Hi,

We have a requirement from our client for power pages. To fulfill the requirement we have created a custom action in Dynamics 365 CRM and tried to execute it from power pages (we have made as public website).

We attempted to perform CRM operations on a power page for an external website. To execute these operations, we need to obtain an authorization token. However, during the token acquisition process, we encountered a CORS error, as indicated below.

Access to XMLHttpRequest at 'https://login.microsoftonline.com/9dedbf2a-1967-42da-b7e3-24a5e2c16475/oauth2/token' from origin 'https://test-demo12345.powerappsportals.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

We are using the below code for the same.
 
var form = new FormData();
            form.append(/grant_type/, /client_credentials/);
            form.append(/client_id/, /Enter Client Id/);
            form.append(/client_secret/, / Enter Client Secret /);
            form.append(/resource/, /Enter CRM URL/);
           
            var settings = {
              /url/: https://login.microsoftonline.com/Enter Tenant Id/oauth2/token/,
              /method/: /GET/,
              /timeout/: 0,
              /headers/: {
                /Cookie/: /fpc=Avy3L6riZPxJsdXm9EXO0xI0P776AQAAALsnF90OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd/,
                /Content-Type/: /application/jsonp/,
                /Access-Control-Allow-Origin/: /*/,
                /Access-Control-Allow-Methods/: /POST,GET,PUT/,
                /Access-Control-Allow-Headers/: /Content-Type,X-Auth-Token,Origin,Authorization/,
              },
              /processData/: false,
              /mimeType/: /multipart/form-data/,
              /contentType/: false,
              /credentials/: /include/,
              /data/: form
            };
           
            $.ajax(settings).done(function (response) {
              alert(response);
            });
 
Note: It is working from postman.

Has anyone else encountered a similar issue and found a solution for it.
 
Thanks!
 
I have the same question (0)
  • Suggested answer
    Likith Profile Picture
    4 on at
    Hello,

    It seems like you're encountering a CORS (Cross-Origin Resource Sharing) issue when attempting to execute CRM operations from a Power Page on an external website.

    Considering the information in Manage your site's Content Security Policy | Microsoft Learn, you can follow below steps to address the issue:
     
    • In the Portal Management app, under Site Settings, review the 'HTTP/Content-Security-Policy' settings. Make sure the 'script-src' directive includes the domains you're making requests to. Adjust as needed to allow communication with 'login.microsoftonline.com'.
    • HTTP/Access-Control-Allow-Origin: User URL of the Microsoft Dataverse instance, such as https://contoso.crm.dynamics.com. To allow any URI to access your resources, use *. 
      This setting controls which domains are allowed to make requests to your Power Pages site. If you want to allow any URI to access your resources, you can set the value to '*'. (
      Set up HTTP headers in Power Pages | Microsoft Learn).

    ​​​​​​​Best regards,
    Likith Khareedu

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 174

#2
ManoVerse Profile Picture

ManoVerse 58 Super User 2026 Season 1

#3
Niki Patel Profile Picture

Niki Patel 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans