Python请求OAuth2Session()传递多个范围参数

时间:2018-03-13 03:37:42

标签: python oauth-2.0 python-requests

我已使用" data_read"成功授权了API连接。作为范围,但是我在将多个范围参数(" data_read"" data_write")传递到OAuth2Session()函数时遇到问题。

需要将多个范围的参数作为

传递到URL字符串中

https://api.website.com/oauth20/authorize?response_type=code&client_id=123456&redirect_uri=https...&范围= DATA_READ&安培;范围= data_write ...

我尝试过使用逗号分隔列表:

scope=["data_read", "data_write"]

导致:

https://api.website.com/oauth20/authorize?response_type=code&client_id=123456&redirect_uri=https...&范围= DATA_READ + data_write

我还尝试在字典中传递范围列表:

dict_scope = {'scope':["data_read", "data_write"]}

导致错误:

ValueError: Invalid scope ({'scope': ['data_read', 'data_write']}), must be string, tuple, set, or list.

我在这里查看过请求文档:

http://docs.python-requests.org/en/master/user/quickstart/#passing-parameters-in-urls

这里:

http://requests-oauthlib.readthedocs.io/en/latest/api.html#oauth-2-0-session

这里有

和OAuth2示例:

http://requests-oauthlib.readthedocs.io/en/latest/examples/examples.html#examples

非常感谢任何想法或建议

0 个答案:

没有答案