我可以轻松获取授权代码,但在尝试将其替换为访问令牌时,我一直遇到错误。
<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>
谷歌说:错误:invalid_request 缺少必需参数:response_type 学到更多 请求详细信息
答案 0 :(得分:12)
您要求的网址是:
https://accounts.google.com/o/oauth2/auth
获取身份验证代码的URL。现在,如果您想获取令牌,则URL应为:
https://accounts.google.com/o/oauth2/token
更改此设置,您的代码应该有效。
答案 1 :(得分:4)
您可能遗漏了response_type=code
response_type
参数确定Google OAuth 2.0端点是否返回授权码。如果您在Web服务器上编写应用程序,则应使用code
。