我正试图从要在python代码中操作的框中检索文件,但是我无法通过python登录。我已经到了允许通过web浏览器访问的地步,如here所述,我可以在授权后在url中看到代码,但我不知道如何以编程方式将代码输入到脚本中
以下是我到目前为止的情况:
sdk = OAuth2(
client_id='[id]',
client_secret='[secret]'
)
auth_url, csrf_token = sdk.get_authorization_url \
('https://account.box.com/api/oauth2/authorize?client_id=[id]&redirect_uri=https://account.box.com/api/oauth2/authorize8&response_type=code')
webbrowser.open(auth_url)
authentication_url = "https://api.box.com/oauth2/token";
params = urlencode({
'grant_type': 'authorization_code',
'assertion': '[CODE]', # this is what I am looking to get
'client_id': '[id]',
'client_secret': '[secret]'
}).encode()
request = Request(authentication_url, params)
response = urlopen(request).read()
access_token = json.loads(response)['access_token']
谢谢你的帮助
目前没有回答
相关问题 更多 >
编程相关推荐