Name: onedrive-connector
Owner: ms-iot
Description: Helps users connect to OneDrive
Created: 2015-10-29 22:05:00.0
Updated: 2017-11-09 16:37:53.0
Pushed: 2016-07-01 21:13:20.0
Homepage: null
Size: 62
Language: C#
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This code block demonstrates how to use the OneDrive APIs from a Universal Application and accelerates the process of using OneDrive in other projects.
The OneDrive Dev Center can be located at https://dev.onedrive.com/ Follow the instructions on the OneDrive Dev Center to register your application. OneDrive requires registration before it will accept requests from you application, and will provide a Client ID and Secret that need to be presented as part of the authorization process your application users will go through.
At this time, this OneDrive connector only does part of the authentication process. Specifically, it implements steps 2 and 3 of the Token Flow, as described in the OneDrive Dev Center. You will need to present a OneDrive login page to the user, and retrieve an access code. That code can then be passed into the “Login” method of this connector. After logging in, commands for file upload to and deletion from OneDrive become one line calls!
To use this block in your project, you need to perform the following steps:
git submodule add https://github.com/ms-iot/onedrive-connector
git submodule update
You should now be able to use onedrive-connector objects in your project.
Note: Everytime you clone your project after it's initial creation, you must run the following commands in the project's root folder:
git submodule init
git submodule update
If the solution is already open in Visual Studio, you may need to reload the solution.
OneDriveConnector(): Initializes the HttpClient that will be used for web calls
Login(string clientId, string clientSecret, string redirectUrl, string accessCode): Logs in to OneDrive. Specifically, exchanges the accessCode for access and refresh tokens, which are used in future requests.
UploadFile(StorageFile file, string destinationPath): Uploads the given storage file object to the specified location on OneDrive.
DeleteFile(string fileName, string pathToFile): Deletes the specified file from the specified location on OneDrive.
Logout(): Sends a logout message to OneDrive to cancel active tokens, and disposes of all user specific information obtained from OneDrive or provided to the Login method.
===
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.