【问题标题】:Google API Python client errorGoogle API Python 客户端错误
【发布时间】:2013-01-19 04:48:43
【问题描述】:

我想要一个用于获取 Google+ 主页供稿的脚本。我用于那个谷歌的script。 client-secrets.json 文件是:

{
 "web": {
   "client_id": "##########",
   "client_secret": "############",
   "redirect_uris": ["http://localhost:8080/oauth2callback/"],
   "auth_uri": "https://accounts.google.com/o/oauth2/auth",
   "token_uri": "https://accounts.google.com/o/oauth2/token",
   "client_email":"##########@developer.gserviceaccount.com",
   "javascript_origins":["http://localhost:8080/"]
        }
}

但是当我想启动这个应用程序时,它会打开一个错误的页面和损坏的机器人:

The redirect URI in the request: http://localhost:8080/ did not match a registered redirect URI

请帮我解决我的问题。

【问题讨论】:

    标签: python api oauth-2.0 google-api-python-client


    【解决方案1】:

    端口 80 上运行本地服务器并简单地设置配置 URL http://localhost 为我修复了它。

    例如适合你的情况

    {
     "web": {
       "client_id": "##########",
       "client_secret": "############",
       "redirect_uris": ["http://localhost/oauth2callback/"],
       "auth_uri": "https://accounts.google.com/o/oauth2/auth",
       "token_uri": "https://accounts.google.com/o/oauth2/token",
       "client_email":"##########@developer.gserviceaccount.com",
       "javascript_origins":["http://localhost"]
            }
    }
    

    【讨论】:

      【解决方案2】:

      我找到了解决方案!您应该创建另一个客户端 ID,但用于桌面应用程序!之后您需要使用它的 client_idclient_secret。它适用于在没有托管的情况下进行开发。

      【讨论】:

      • 你让我度过了一个美好的夜晚。我花了 2 个小时才找到这个答案,谷歌需要聘请其他人为他们编写文档。
      【解决方案3】:

      您用于client_idclient_secret 的值对应于您已创建并将通过以下方式访问的Google API 项目

      https://code.google.com/apis/console/?pli=1#project:XYZ

      XYZ 是您的项目 ID。

      在这个项目中,您需要确保 http://localhost:8080/ 是一个重定向 URI

      1. 点击右侧的“APIs Access”标签
      2. 为您的应用找到相应的“Web 应用程序的客户端 ID”框
      3. 点击“编辑设置...”
      4. http://localhost:8080/ 添加到“授权重定向 URI”框

      【讨论】:

      • The redirect URI in the request: http://localhost:8080/ did not match a registered redirect URI
      猜你喜欢
      • 2012-12-01
      • 2014-06-18
      • 2016-06-07
      • 1970-01-01
      • 2015-10-31
      • 2016-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多