我遇到了这个错误。 我刚刚成功收到授权码,我正在尝试将其换成访问令牌,但是我收到错误消息“invalid_request”。
我正在使用Apache HttpComponents库(当前版本)来处理请求,并在我发布帖子请求时使用UrlEncodedFormEntity。
这是我的请求信息:
Request body: scope=&client_secret=[my_secret]&grant_type=authorization_code&redirect_uri=http%3A%2F%2Fmydomain.org%3A8080%2F[some parameters etc...]%3FplatformID%3D3&client_id=23[...]-rg[...].apps.googleusercontent.com&code=[my_encoded_authorizationCode]
Request-URL: https://accounts.google.com/o/oauth2/token
Request-Method: POST
Request headers --
User-Agent = MAC: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25 // this is a fake user agent I have set by the header manipulation
Content-Type = application/x-www-form-urlencoded
Response headers --
Cache-Control = no-cache, no-store, max-age=0, must-revalidate
Pragma = no-cache
Expires = Fri, 01 Jan 1990 00:00:00 GMT
Date = Sun, 02 Dec 2012 11:44:34 GMT
Content-Type = application/json
X-Content-Type-Options = nosniff
X-Frame-Options = SAMEORIGIN
X-XSS-Protection = 1; mode=block
Server = GSE
Transfer-Encoding = chunked
Response:
{
"error" : "invalid_request"
}
有任何帮助吗? 我被困了好几天,研究和实施其他OAuth2协议,但谷歌的协议不起作用......
致以最诚挚的问候和感谢, 马丁博里斯