谷歌oauth2.0 405错误

use*_*619 6 oauth google-api google-oauth google-oauth2

我试图使用谷歌oauth使用以下链接,但得到405错误,

如果参数正确,你能告诉我吗?

client_id = changed to a diff value
response_type = code
scope= openid%20email
redirecturl = given the value based on what I registered in console.developers.com
login_hint = my gmail id..

https://accounts.google.com/o/oauth2/token?
 client_id=690178314820-85fvo4eq56se4mppdaf0pt6tnnjo552&
 response_type=code&
 scope=openid%20email&
 redirect_uri=http://test.webfactional.com&
 state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&
 login_hint=myemail@gmail.com
Run Code Online (Sandbox Code Playgroud)

我在浏览器中做了上面的get请求..

Owe*_*Cao 0

看来您使用了错误的 api,您应该使用https://accounts.google.com/o/oauth2/auth而不是https://accounts.google.com/o/oauth2/token.

出现405错误的原因是https://accounts.google.com/o/oauth2/token只能通过POST调用,并且是为了获取token。您需要先获取授权码,然后将其兑换为令牌。