Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

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

$
0
0

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


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>