OneDrive / onedrive-sdk-python

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

We're unable to complete your request invalid_request: The provided value for the input parameter 'redirect_uri' is not valid. The expected value is a URI which matches a redirect URI registered for this client application. #197

Closed Dskpupper closed 2 years ago

Dskpupper commented 2 years ago

I mentioned my redirect uri while registering and created id and password, but when i click the link i get this error msg in the browser . 2

image

What should be redirect_uri? Im trying to connect my personal onedrive with this python code

This is the redirect uri im using redirect_uri = 'http://localhost:8080/'

Dskpupper commented 2 years ago

2nd method worked,

ArnaudCampestre commented 2 years ago

Hi, I am in the same situation as you were and cannot pass the error page about reditect_uri. I cannot see what is the 2nd method you mentioned, would mind sharing it with me please, it would help a lot. Thank you

KTibow commented 2 years ago

@ArnaudCampestre try using this code instead:

import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer

redirect_uri = 'http://localhost:8080/'
client_secret = 'your_app_secret'
scopes=['wl.signin', 'wl.offline_access', 'onedrive.readwrite']

client = onedrivesdk.get_default_client(
    client_id='your_client_id', scopes=scopes)

auth_url = client.auth_provider.get_auth_url(redirect_uri)

#this will block until we have the code
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)

client.auth_provider.authenticate(code, redirect_uri, client_secret)
ArnaudCampestre commented 2 years ago

@KTibow Thank you very much for your help, it worked brilliantly. Have a good one and thank you again