简体   繁体   中英

Office365 javascript file picker

I'm trying to find a js file picker for Office365 docs. 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.

Glenn Ferrie is correct, there are different APIs you'll need to use depending upon what your specific use-case is.

Here is the 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. For the sake of this topic, let's assume you're using Office365 and OneDrive via the OneDrive Web Picker SDK (from above):

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

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 .

In the code sample to load the SDK object you'll replace APP_ID with your client_id (from your Live.com developer console):

<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. (It may or may not operate there...but is worth being aware of before hand).

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