gpt4 book ai didi

python - 如何在python中获取Box的授权码

转载 作者:行者123 更新时间:2023-12-01 05:47:07 27 4
gpt4 key购买 nike

我被困在“获取访问 token ”部分。在文档中,我需要一个“代码”。但是如何获取授权码呢?我正在使用Python。

    authorize_url = 'https://www.box.com/api/oauth2/authorize?response_type=code&client_id=MY_CLIENT_ID'

def myRequest(path, method=None, options=None):
response = requests.request(method, path, **options)
return json.dumps(response.json())

code = myRequest(
path=authorize_url,
method='GET',
options={
'headers':{
'response_type': 'code',
'client_id': CLIENT_ID,
}
}
)

最佳答案

您必须使用模块来发出 HTTP 请求,例如requestsurllib并按照指示 here 进行操作.

我在这里设置了一个非常简单的 Flask 应用程序:https://github.com/seanrose/box-oauth2-example

将用户发送到 Box 的授权 URL 后,“代码”将返回到您的应用。

关于python - 如何在python中获取Box的授权码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15709299/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com