我可以轻松获得授权代码,但是尝试将其交换为访问 token 时,总是会出错。

    <FORM action="https://accounts.google.com/o/oauth2/auth" method="post">

<input type = "hidden" name = "code" value = "4%2FXR0s9YvmROnHOpNUuiSlfxHE7xj-">

<input type = "hidden" name = "redirect_uri" value = "http%3A%2F%2Fwww.m1448analytics.com%2Foauth2%2Frecv.php">

<input type = "hidden" name = "client_id" value = "502294831256-84q1ar05j14knsh5h2msvofu68e7rpaj.apps.googleusercontent.com">

<input type = "hidden" name = "scope" value = "">

<input type = "hidden" name = "client_secret" value = "hiding it">

<input type = "hidden" name = "grant_type" value = "authorization_code">

<INPUT type="submit" value="Send">

</FORM>

Google说:错误:invalid_request
缺少必需的参数:response_type
学到更多
索取详细资料

最佳答案

您请求的URL是:

https://accounts.google.com/o/oauth2/auth

这是用于获取身份验证代码的URL。现在,如果要获取 token ,则URL应该为:
https://accounts.google.com/o/oauth2/token

更改此设置,您的代码应该可以正常工作。

10-07 13:12
查看更多