invalid_client onedrivesdk身份验证错误

时间:2019-02-19 15:26:19

标签: python

我已经看过上一篇文章,并且没有提供潜在的解决方案:

invalid_client error with Python OneDrive SDK

我下面的脚本正在尝试验证我的应用程序,以便我可以将文件上传到SPOnline:

import onedrivesdk
import adal  #, uuid, time
from msrestazure.azure_active_directory import AADTokenCredentials

client_id = 'dc185bb4-66b1-4270-86be-45a6a6bcda94' #'<CLIENT_ID>'
authority_host_uri = 'https://login.microsoftonline.com' #'https://login.microsoftonline.com'
tenant = '4a653e38-cdfe-4046-8620-e0fa13765079'  #'<TENANT>'   
authority_uri = authority_host_uri + '/' + tenant
resource_uri = 'https://graph.microsoft.com' #https://management.core.windows.net' 
client_secret = '<CLIENT_SECRET>' #'<CLIENT_SECRET>'
scopes=['wl.signin', 'wl.offline_access', 'onedrive.readwrite']
redirect_uri='https://localhost:8080'

context = adal.AuthenticationContext(authority_uri, api_version=None)
mgmt_token = context.acquire_token_with_client_credentials(resource_uri, client_id, client_secret)

##token_response = auth_context.acquire_token_with_authorization_code(code,REDIRECT_URI,config.RESOURCE, config.CLIENT_ID, config.CLIENT_SECRET)

credentials = AADTokenCredentials(mgmt_token, client_id)

print(mgmt_token)

client = onedrivesdk.get_default_client(client_id='dc185bb4-66b1-4270-86be-45a6a6bcda94', scopes=scopes)
client.auth_provider.authenticate(mgmt_token, redirect_uri, client_secret)

f = onedrivesdk.Folder()
i = onedrivesdk.Item()
i.name = 'TestFolderPython'
i.folder = f


returned_item = client.item(drive='me', id='root').children.add(i)

还有其他人遇到此身份验证错误吗?

0 个答案:

没有答案