【问题标题】:Using OAuth 2.0 for Installed Applications将 OAuth 2.0 用于已安装的应用程序
【发布时间】:2016-02-16 16:31:49
【问题描述】:

我正在编写一个命令行工具(installedApp),它需要访问用户的 Google 表格。为此,我需要从用户那里获取访​​问令牌。

我正在遵循这些准则OAuth2InstalledApp。到目前为止,我设法通过使用http://localhost 类型的redirect_uri 来获取授权码。我将http://localhost:7373/authorizationCode 指定为redirect_uri,并且我有一个本地服务器正在侦听端口7373。

但是当我发出获取访问令牌的请求时,我得到一个带有

的 HTTP 400 错误请求响应

redirect_uri_mismatch 错误

。当我发出请求时,redirect_uri 被定义为“您从开发者控制台获得的重定向 URI”。这是错误的,因为当您创建已安装的应用程序时,您无法指定重定向 uri(仅适用于 Web 应用程序)。 https://infinit.io/_/i48b2rM

所以我的问题是我做错了什么?

【问题讨论】:

    标签: node.js google-oauth google-identity


    【解决方案1】:

    当您在 Google Developers Console 中创建客户端 ID 时,系统会为您创建两个 redirect_uri:urn:ietf:wg:oauth:2.0:oobhttp://localhost。您也可以考虑urn:ietf:wg:oauth:2.0:oob:auto。您的应用程序使用的值决定了授权码如何返回到您的应用程序。 choose a redirect uri

    【讨论】:

      猜你喜欢
      • 2015-09-25
      • 2014-03-26
      • 2011-02-03
      • 2014-09-04
      • 2016-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多