【问题标题】:Google OAuth2 response_type error on authorization code request授权代码请求上的 Google OAuth2 response_type 错误
【发布时间】:2019-01-21 08:31:45
【问题描述】:

我正在尝试从 Google+ API 获取授权码,如Step 1(Set authorization parameters) (HTTP/REST) 中所述。

正如我在那里读到的,Google 授权服务器具有以下强制性查询字符串参数:client_idredirect_uriscope,所以我的 href 看起来像这样:

https://accounts.google.com/o/oauth2/v2/auth?client_id=123002756467-dmq0soo7rlfc4on640hdsehnrvb700t7.apps.googleusercontent.com&redirect_uri=http://localhost:5000/oAuthCallback&scope=https://www.googleapis.com/auth/glass.location

尝试访问该链接时,我收到以下错误: 错误:invalid_request(缺少必需参数:response_type)

但是,response_type 参数根本没有在该参数列表中指定!

有什么办法可以解决这个问题吗?

已修复。似乎我的代码编辑器中的空格也作为“%20”插入到我的链接中,所以这就是它不起作用的原因。

【问题讨论】:

  • 检查 OAuth2 响应类型:tools.ietf.org/html/rfc6749#section-3.1.1
  • @Edwin,即使在指定了 response_type 参数后,我也会得到同样的错误
  • 在第 2 步中,您指定了 response_type + 其他参数,您尝试过吗?
  • response_type=code

标签: javascript oauth authorization google-oauth


【解决方案1】:

由于您遵循服务器文档,因此 response_type=code 参数出现在下一步 [1] 的示例授权请求 URL 中。

您可以在此处了解有关响应类型的更多信息:https://developers.google.com/identity/protocols/OpenIDConnect#response-type

[1]https://developers.google.com/identity/protocols/OAuth2WebServer#redirecting

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-03
    • 2018-05-02
    • 1970-01-01
    相关资源
    最近更新 更多