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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Upload documents to SharePoint Online from Dynamics 365 Web Resource (SPA)

(0) ShareShare
ReportReport
Posted on by 120

My requirement is to develop a Single-Page-App (SPA) using ReactJS.

This SPA will be placed as a Web Resource displayed in an Entity Form, it will also allow users to upload Documents to SharePoint. The user must not see any login pages if the user is already logged in to Dynamics 365. 

I tried two things to access SharePoint REST API, msal.js and adal.js.
With msal, according to this issue, iframes are not supported for security reasons. 

So my next option was using adal.js. I tried to run the following:

  var organizationURI = "https://[my org].crm6.dynamics.com"; //The URL of your Dynamics 365 for Customer Engagement organization  
        var tenant = "203947d7-.........."; //The name of the Azure AD organization you use  
        var clientId = "3f7a9929-.............."; //The ClientId you got when you registered the application  
        var pageUrl = "https://[my org].crm6.dynamics.com/WebResources/hfnz_dummy.html"; //The URL of this page in your development environment when debugging.  

        window.config = {
            clientId: clientId,
            tenant: tenant,
            redirectUri: pageUrl,
            postLogoutRedirectUri: pageUrl,
            endpoints: {
                orgUri: organizationURI
            },
            cacheLocation: 'localStorage',
        };
        var ac = new AuthenticationContext(config);
        ac.login();
        ac.acquireToken(organizationURI, retrieveAccounts);

However, I keep getting this error

Refused to display 'login.microsoftonline.com/.../authorize;..........' in a frame because it set 'X-Frame-Options' to 'deny'.

Unfortunate, couldn't find any useful links on achieving this in dynamics 365 online.

I literally spent days and days on this and started to question my sanity.

What am I doing wrong here?

NOTE: I read this article and tried to implement it using adal and msal but with no luck. The author did not share any code samples.
community.dynamics.com/.../getting-a-sharepoint-oauth-access-token-in-a-dynamics-365-web-resource

*This post is locked for comments

I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans