简体   繁体   中英

Remotely accessing Sharepoint 2013 using REST on Office 365 from JavaScript

I want to integrate with SkyDrive Pro for file storage from a browser page directly, so I don't want to do this from our web server.

Almost every example I've seen of doing this involves either running code hosted inside Sharepoint itself or remotely over using C# in ASPX hosted on another site.

Can anyone point me to a pure JavaScript example that would run solely in an HTML page (NO server side code).

From what I can tell, this is possible, but nearly every authentication example uses C# libraries again. It doesn't look like they provide a client-side JavaScript library similar to the Windows Live SDK and it probably means constructing json/xml for the auth request.

Ideally, I want to simply popup the Office365 logon screen to authenticate and then be able to make API calls from my page using the browser session cookie.

This does not seem to be possible:

Note that you cannot obtain an access token from code that is running on a browser client. You must obtain the access token from code that is running on a server and make it available to the client-side code (by using a cookie, URL parameter, etc.).

Source: http://msdn.microsoft.com/en-us/library/jj164022%28v=office.15%29.aspx

Your server side code needs to be in a sort of trust relationship with the identity server (Azure Access Control Services) in that they share a client ID and client secret (generated when your app is installed in Sharepoint as an app principal). See steps 6 and 7 of the process here: http://msdn.microsoft.com/en-us/library/fp142382

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM