![](/img/trans.png)
[英]Google Buzz API - Unable to resolve error: “Required Parameter Missing - grant_type”
[英]Google OAuth error Required parameter is missing: grant_type
我正在嘗試以下代碼:
import requests
url_token = 'https://accounts.google.com/o/oauth2/token'
params = {
'code': request.values.get('code', '', type=str),
'client_id': app.config['SOCIAL_GOOGLE']['consumer_key'],
'client_secret': app.config['SOCIAL_GOOGLE']['consumer_secret'],
'redirect_uri': urllib.quote_plus("https://example.com/google/code"),
'grant_type': 'authorization_code'
}
out = requests.post(url_token, params=params)
在Flask中使用Python-Request。 但是我得到了錯誤響應:
ERROR - out={
"error" : "invalid_request",
"error_description" : "Required parameter is missing: grant_type"
}
這是標准的POST請求。 關於Google為什么看不到grant_type參數的任何提示? 還是誤導性錯誤消息?
params
用於在GET請求中向URL添加查詢參數, data
用於將數據傳遞給POST請求,因此您應將POST參數的形式傳遞為:
out = requests.post(url_token, data=params)
請參閱以下位置的文檔: http : //docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.