Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authentication OneDrive Python API

I am trying to use my OneDrive for business with Python.

I have installed onedrivesdk and now I am in the process of authenticating my OneDrive

the code provided is the following

import onedrivesdk

redirect_uri = 'http://localhost:8080/'
client_secret = 'your_client_secret'
client_id='your_client_id'
api_base_url='https://api.onedrive.com/v1.0/'
scopes=['wl.signin', 'wl.offline_access', 'onedrive.readwrite']

http_provider = onedrivesdk.HttpProvider()
auth_provider = onedrivesdk.AuthProvider(
http_provider=http_provider,
client_id=client_id,
scopes=scopes)

client = onedrivesdk.OneDriveClient(api_base_url, auth_provider, http_provider)
auth_url = client.auth_provider.get_auth_url(redirect_uri)

I am not sure what is the client_secret and client_id I should provide to get access to my OneDrive

I will appreciate help regarding from where to get the above mentioned parameters.

like image 566
Mariano Avatar asked Jul 14 '17 21:07

Mariano


People also ask

Can python connect to OneDrive?

You can import and use the onedrive SDK API for python. You can authenticate and perform operations such as upload/download/rename etc.


1 Answers

The client_secret and client_id are two required parameters needed to use OAuth2, which is an industry-standard protocol for authorization.

Take a look at these following links to know how to get these information related to OneDrive access:

https://dev.onedrive.com/auth/msa_oauth.htm

Get Access Token with OneDrive API

You will need to register your application following this link: https://dev.onedrive.com/app-registration.htm

After that, your application will receive some request and, with valid user credentials, get access to OneDrive account.

I hope it helps.

like image 186
Dalton Cézane Avatar answered Sep 19 '22 17:09

Dalton Cézane