Python 授权 imgur 使用 OAuth2.0 认证获取 subreddit 画廊
我正在尝试访问imgur的API,以获取某个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}'
我不太确定我哪里做错了,这样传递我的client_id和响应类型是不是不对?
1 个回答
2
快速查看一下文档可以发现:
https://api.imgur.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&response_type=REQUESTED_RESPONSE_TYPE&state=APPLICATION_STATE
这些是获取参数,而不是请求头。所以你需要把字典作为 params
传递,而不是 headers
。