wor*_*ith 6 oauth oauth-2.0 google-oauth
我相信我在OAuth文档中运行确切的POST请求(使用我的凭据),但是我收到400错误.我收到了404错误,但随后重置了我的client_secret并开始使用新的client_secret,现在收到错误的请求错误.我有什么想法我做错了吗?
$.ajax({
url:'https://www.googleapis.com/oauth2/v4/token',
data:{
'code':getParameterByName('code'),
'client_id':'',
'client_secret':'',
'redirect_uri':encodeURI(url+'?mail=tokened'),
'grant_type':'authorization_code'
},
dataType:'json',
method:'POST',
success:function(response){console.log(response);}});
Run Code Online (Sandbox Code Playgroud)
这可能不太可能,但根据使用 OAuth 2.0 for Web Server 应用程序(处理 OAuth 2.0 服务器响应部分)中提供的 HTTP/REST 示例,您应该发送内容类型为 的负载,application/x-www-form-urlencoded而不是 JSON。
application/x-www-form-urlencoded除了规范中提到的之外,我还看到其他 OAuth 实现接受 JSON 负载,但也许 Google 实现更严格。
| 归档时间: |
|
| 查看次数: |
2127 次 |
| 最近记录: |