无法使用php表单在Google oauth上交换令牌的授权码

Vic*_*ekh 2 php oauth

我可以轻松获取授权代码,但在尝试将其替换为访问令牌时,我一直遇到错误.

    <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>
Run Code Online (Sandbox Code Playgroud)

谷歌说:错误:invalid_request缺少必需参数:response_type了解更多请求详细信息

bhu*_*vin 12

您要求的URL是:

https://accounts.google.com/o/oauth2/auth
Run Code Online (Sandbox Code Playgroud)

哪个是获取身份验证代码的URL.现在,如果您想获取令牌,则URL应为:

https://accounts.google.com/o/oauth2/token
Run Code Online (Sandbox Code Playgroud)

改变这一点,你的代码应该有效.