Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python授权imgur OAuth2.0身份验证以获取subreddit gallery_Python_Api_Authentication_Imgur - Fatal编程技术网

Python授权imgur OAuth2.0身份验证以获取subreddit gallery

Python授权imgur OAuth2.0身份验证以获取subreddit gallery,python,api,authentication,imgur,Python,Api,Authentication,Imgur,因此,我试图访问imgurapi,以获取某个reddit子库中的图像列表。这就是我迄今为止所尝试的: >>> header = {'client_id': 'thisismyclientid', 'response_type': 'pin'} >>> r = requests.get('https://api.imgur.com/oauth2/authorize', headers=header, verify=False) >>> r.te

因此,我试图访问imgurapi,以获取某个reddit子库中的图像列表。这就是我迄今为止所尝试的:

>>> header = {'client_id': 'thisismyclientid', 'response_type': 'pin'}
>>> r = requests.get('https://api.imgur.com/oauth2/authorize', headers=header, verify=False)
>>> r.text
u'{"data":{"error":"client_id and response_type are required","request":"\\/oauth2\\/authorize","parameters":"","method":"GET"},"success":false,"status":400}'

不完全确定我做错了什么,这不是传递客户id和响应类型的正确方法吗?

快速查看文档可以发现:

https://api.imgur.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&response_type=REQUESTED_RESPONSE_TYPE&state=APPLICATION_STATE

这些是get参数,而不是标题。因此,您必须将字典作为
params
传递,而不是
标题

非常感谢!我真不敢相信我竟然没有意识到这一点:万分感谢!没问题。我建议不要使用
verify=False
(如果您使用的是python 2,则必须这样做,否则它将无法工作)。如果您有python3.2,请尝试删除
verify=False