[英]Get access token for google by using Python requests library
Trying to get the access token in response for google but can't figure out what I'm doing wrong. 试图获取访问令牌作为对Google的响应,但无法弄清楚我在做什么错。
This is what I've done so far: 到目前为止,这是我所做的:
import requests
authorization_code_req = {
'client_id':'key',
'client_secret':'key',
'redirect_uri':'http://localhost:5000',
'grant_type':'authorization_code'}
r = requests.get('https://accounts.google.com/o/oauth2/token',
params=authorization_code_req)
print (r)
you should send authorization_code_req
as json
and not as params
. 您应该以
json
而不是params
发送authorization_code_req
。 So your code should look something like this: 因此,您的代码应如下所示:
import requests
authorization_code_req = {
'client_id':'key',
'client_secret':'key',
'redirect_uri':'http://localhost:5000',
'grant_type':'authorization_code'
}
r = requests.get('https://accounts.google.com/o/oauth2/token',
json=authorization_code_req)
print(r)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.