OneDrive / onedrive-sdk-python

OneDrive SDK for Python! https://dev.onedrive.com
MIT License
1.08k stars 189 forks source link

onedrive-sdk-fork, how to get client_id correctly? #201

Closed thangld201 closed 2 years ago

thangld201 commented 2 years ago

I installed onedrive-sdk-fork (after seeing that onedrive-sdk fails to work under any usecases), then tried the following code (in README):

import onedrivesdk_fork as onedrivesdk

redirect_uri = 'http://localhost:8080/'
client_secret = 'client_secret'
client_id='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)
print('Paste this URL into your browser, approve the app\'s access.')
print('Copy everything in the address bar after "code=", and paste it below.')
print(auth_url)
code = input('Paste code here: ')
client.auth_provider.authenticate(code, redirect_uri, client_secret)

I followed here to generate a client id (I don't create client secret).

Then I opened the url in the terminal and get redirected to a microsoft page, where I got the error:

We're unable to complete your request

unauthorized_client: The client does not exist or is not enabled for consumers. If you are the application developer, configure a new application through the App Registrations in the Azure Portal at https://go.microsoft.com/fwlink/?linkid=2083908.

My question is how can I get the proper client_id ? (I have a onedrive account)

P/s: I'm attempting to mount my onedrive storage onto Google Colaboratory. Previously I tried with Rclone, which seemed fine at first but are actually unstable. Often, files that I write to onedrive through Rclone don't show up in onedrive storage for unknown reasons, quite irritating to be honest. If you know anyway to resolve this please help me !

thangld201 commented 2 years ago

Could you help me @KTibow ?

KTibow commented 2 years ago

You need to modify the

client_secret = 'client_secret'
client_id='client_id'

part with credentials from Azure (link was old, it might not work).

thangld201 commented 2 years ago

Thanks for the reply @KTibow. I just realize that my account is OneDrive for Business. As you answered here, sadly, this library doesn't work for OneDrive Business anymore. Still, I appreciate your help a lot.