Rails Google Oauth2 - 项目中未使用旧版 People API

Posted

技术标签:

【中文标题】Rails Google Oauth2 - 项目中未使用旧版 People API【英文标题】:Rails Google Oauth2 - Legacy People API has not been used in project 【发布时间】:2020-04-21 13:14:26 【问题描述】:

我正在努力使用omniauth google oauth2 gem 为 google oauth2 设置应用程序。我目前有另一个模型使用不同的 oauth 提供程序,所以这需要我进行一些配置。

我能够很好地配置应用程序,并且可以点击路由 localhost:3000/auth/google_oauth2 以进入 google auth 提示符。从那里,我选择了我的谷歌帐户,它尝试重定向到我的回调,但我收到了这个错误


  "error": 
    "code": 403,
    "message": "Legacy People API has not been used in project <PROJECT_ID> before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=<PROJECT_ID> then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "status": "PERMISSION_DENIED",
    "details": [
      
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=<PROJECT_ID>"
          
        ]
      
    ]
  

当我转到谷歌开发者控制台中提供的https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=&lt;PROJECT_ID&gt; 链接时,我从谷歌收到此错误

There was an error while loading /apis/api/legacypeople.googleapis.com/overview?project=<PROJECT_ID>. Please try again.

这很有意义,因为该 API 已不再使用。在我的谷歌项目中,我启用了以下 API

联系人 API Google+ API 人员 API

试图收集我在网上找到的东西来拼凑起来。但是,目前这些都不起作用。

有谁知道我如何通过 google oauth2 Legacy People API 错误?

【问题讨论】:

【参考方案1】:

将 omniauth-google-oauth2 更新到 0.8.0 或更高版本可避免该错误:

 bundle update --source omniauth-google-oauth2

参考https://github.com/zquestz/omniauth-google-oauth2/issues/377

【讨论】:

以上是关于Rails Google Oauth2 - 项目中未使用旧版 People API的主要内容,如果未能解决你的问题,请参考以下文章

Google Adwords API with OAuth2 如何获取授权用户的电子邮件?

Rails Google Client API - 无法用刷新令牌交换访问令牌

如何使用 google.oauth2 python 库?

Google OAuth2 不适用于移动设备

Google App Engine 烧瓶 SSL 和 OAuth2 问题

Google OAuth2 服务帐户 API 授权