简体   繁体   English

通过JavaScript在Office 365上使用REST远程访问Sharepoint 2013

[英]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. 我想与SkyDrive Pro集成以直接从浏览器页面进行文件存储,所以我不想从我们的Web服务器上进行此操作。

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. 我所见过的几乎每个示例都涉及运行在Sharepoint本身中托管的代码,或者通过在另一个站点上托管的ASPX中使用C#远程运行。

Can anyone point me to a pure JavaScript example that would run solely in an HTML page (NO server side code). 谁能指出我一个仅在HTML页面中运行的纯JavaScript示例(没有服务器端代码)。

From what I can tell, this is possible, but nearly every authentication example uses C# libraries again. 据我所知,这是可能的,但是几乎每个身份验证示例都再次使用C#库。 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. 看起来他们没有提供类似于Windows Live SDK的客户端JavaScript库,这可能意味着为auth请求构造json / xml。

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. 理想情况下,我只想弹出Office365登录屏幕进行身份验证,然后能够使用浏览器会话cookie从我的页面进行API调用。

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.). 您必须从服务器上运行的代码获取访问令牌,并将其提供给客户端代码使用(通过使用cookie,URL参数等)。

Source: http://msdn.microsoft.com/en-us/library/jj164022%28v=office.15%29.aspx 来源: 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). 您的服务器端代码需要与身份服务器(Azure访问控制服务)建立某种信任关系,因为它们共享一个客户端ID和客户端密钥(当您将应用程序作为应用程序主体安装在Sharepoint中时生成)。 See steps 6 and 7 of the process here: http://msdn.microsoft.com/en-us/library/fp142382 请参阅此处的过程的步骤6和7: http : //msdn.microsoft.com/zh-cn/library/fp142382

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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