简体   繁体   English

Office365 javascript文件选择器

[英]Office365 javascript file picker

I'm trying to find a js file picker for Office365 docs. 我正在尝试为Office365文档找到一个js文件选择器。 I found the OneDrive file picker https://msdn.microsoft.com/en-us/library/jj219328.aspx but I can't seem to get it to work with Office 365 as I keep getting an invalid client response when I try to authenticate against my azure AD associated with my Office365. 我找到了OneDrive文件选择器https://msdn.microsoft.com/en-us/library/jj219328.aspx但我似乎无法让它与Office 365一起使用,因为当我尝试时我一直收到无效的客户端响应验证与我的Office365相关的天蓝色广告。

Glenn Ferrie is correct, there are different APIs you'll need to use depending upon what your specific use-case is. Glenn Ferrie是正确的,根据您的具体用例,您需要使用不同的API。

Here is the OneDrive Web Picker SDK (JavaScript): https://dev.onedrive.com/sdk/javascript-picker-saver.htm 以下是OneDrive Web Picker SDK(JavaScript): https//dev.onedrive.com/sdk/javascript-picker-saver.htm

As far as the authentication portion of your app failing, this is going to depend upon which APIs you're using. 至于应用程序的身份验证部分失败,这将取决于您正在使用的API。 For the sake of this topic, let's assume you're using Office365 and OneDrive via the OneDrive Web Picker SDK (from above): 为了本主题,我们假设您通过OneDrive Web Picker SDK(来自上方)使用Office365和OneDrive:

You'll need to make sure you have your app registered here so you can obtain the necessary API keys (client_id and client_secret): https://account.live.com/developers/applications 您需要确保在此处注册了您的应用,以便获得必要的API密钥(client_id和client_secret): https//account.live.com/developers/applications

This app code should live on a server which exposes the redirect URI you'll register with your app (this endpoint should be able to handle the data which Micro$oft will post to your redirect endpoint appropriately) on this page: https://account.live.com/developers/applications/apisettings . 此应用程序代码应该存在于服务器上,该服务器公开您将在应用程序中注册的重定向URI(此端点应该能够处理Micro $ oft将适当地发布到您的重定向端点的数据): https:// account.live.com/developers/applications/apisettings

In the code sample to load the SDK object you'll replace APP_ID with your client_id (from your Live.com developer console): 在加载SDK对象的代码示例中,您将使用client_id(来自Live.com开发人员控制台)替换APP_ID

<script type="text/javascript" src="https://js.live.net/v5.0/OneDrive.js" id="onedrive-js" client-id="APP_ID"></script>

You should now be able to follow along with the remainder of the example code to get you moving in the right direction: 您现在应该能够按照示例代码的其余部分来使您朝着正确的方向前进:

  1. Define your picker options, including success and cancel handlers 定义选择器选项,包括成功和取消处理程序
  2. Define how you want to open the picker interface button 定义打开选择器界面按钮的方式
  3. Handling a successful response and the file data 处理成功的响应和文件数据

The linked page above provides example code for all of this and should be sufficient to get you moving in the right direction. 上面的链接页面提供了所有这些的示例代码,应该足以让您朝着正确的方向前进。

I was helping on another question earlier for someone who wanted to be able to open the picker from mobile web browsers. 我之前正在帮助那些希望能够从移动网络浏览器打开选择器的人。 While I didn't do extensive testing, I did test that the documentation page for the OneDrive Web Picker SDK (JavaScript) loaded the file picker on my desktop browser...I was unable to get that same picker to load in the mobile versions of the browsers. 虽然我没有进行大量测试,但我测试了OneDrive Web Picker SDK(JavaScript)的文档页面在我的桌面浏览器上加载了文件选择器...我无法在移动版本中加载相同的选择器的浏览器。 (It may or may not operate there...but is worth being aware of before hand). (它可能会或可能不会在那里运作......但值得在手边了解)。

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

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