python oauth2中的未授权客户端错误

时间:2019-07-24 02:21:56

标签: python api oauth-2.0

尝试进行API调用以接收访问令牌时,我收到未经授权的客户端错误

import requests, json
import subprocess
import sys
from requests_oauthlib import oauth2_session

authorize_url = 'https://id.xxx.com/connect/authorize'
token_url = 'https://id.xxx.com/connect/token'
redirect_uri = 'httpsxxxlocalhost'
test_api_url = 'https://id.xxxx.com/connect/authorize'
client_id = 'xxxxx'
client_secret = 'xxxxxxxxxxx'
scope = 'read offline_access read_jobad'

authorization_redirect_url = authorize_url + '? 
response_type=code&client_id=' + client_id + '&redirect_uri=' + 
redirect_uri + '&scope=read offline_access read_jobad'
print ('go to the following url on the browser and enter the code from 
the returned url: ')
print ('---  ' + authorization_redirect_url + '  ---')
authorization_code = input()
print(authorization_code)

data = {"client_id":client_id, "client_secret":client_secret, 
    "grant_type":"authorization_code", "code":authorization_code, 
"redirect_uri":redirect_uri}
print(data)

response = requests.post(token_url, data=data)
print(response.json())

不知道我在这里做错了什么(python noob)

0 个答案:

没有答案
相关问题