OneDrive / onedrive-sdk-python

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

Authentication error: unauthorized_client #178

Open fei-fang opened 4 years ago

fei-fang commented 4 years ago

I wanna try running the following code:

_redirect_uri = 'http://localhost:8080/' client_secret = '***' client_id='700d805e-d442-4af0-a4b1-b17a1201bb5f' 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(redirecturi)

But when I click the auth_url to do authentication, the website shows as:

_We're unable to complete your request: unauthorizedclient: 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 app details are shown below:

Annotation 2020-04-03 123602 Annotation 2020-04-03 123601

Does anyone have an idea why this will occur?

fei-fang commented 4 years ago

fyi, I'm using an organization account

KTibow commented 4 years ago

Make sure you copy just the URL, no quotes. You can share it and hide details if needed.

fei-fang commented 4 years ago

Make sure you copy just the URL, no quotes. You can share it and hide details if needed.

Hi KTibow,

Thank you for your reply! If you mean the redirect URL, I'm quite sure I copy the right URL 'http://localhost:8080/'. Because I used my own personal account to try this yesterday, it worked well. So I think the issue may be from my official account settings, do you know what settings or access should the account satisfy to achieve this api?

Thanks!

KTibow commented 4 years ago

I don't really know about different types of accounts. By exactly, I mean the bit where it gives you the URL that you open in your browser.

skye10 commented 3 years ago

fei-fang, did you solve it? I have the same issue exactly.

My code:

redirect_uri = 'http://localhost:8080/'
client_secret = '****'
client_id='924a6f74-66f5-4ff7-9c62-24f2141feb08'
api_base_url='https://api.onedrive.com/v1.0/'
scopes=['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)
# Ask for the code
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)

When I paste the 'auth_url' in the browser I get:

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.

jseguelh commented 2 years ago

i have the same problem, did you find the solution?

KTibow commented 2 years ago

Make sure in Azure the redirect URI is correct.