Google加上API今天已关闭,可以使用哪种替代方式进行身份验证? [英] Google plus API shutdown today, which alternative can be used to authentication?

查看:116
本文介绍了Google加上API今天已关闭,可以使用哪种替代方式进行身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用rails-4,并且已在我的应用程序中使用OAuth-2Google+ API进行身份验证,为此使用了以下gem:

I am using rails-4, and have used OAuth-2 for authentication with Google+ API, for which the following gems are used, in my app:

  1. omniauth-oauth2
  2. omniauth-google-oauth2

我已经收到以下以下电子邮件通知:

I have received the following prior email notice:

2019年3月7日,所有Google+ API和Google+登录将关闭 完全地.这将是逐步关闭,并开始API调用 最早在2019年1月28日间歇性地失败,并且Google+范围的OAuth请求>最早在2019年2月15日开始间歇性地失败.

On March 7, 2019, all Google+ APIs and Google+ Sign-in will be shut down completely. This will be a progressive shutdown, with API calls starting to intermittently fail as early as January 28, 2019, and OAuth requests > for Google+ scopes starting to intermittently fail as early as February > 15, 2019.

今天,我无法进行身份验证,因为在API收到以下代码后,我得到了request.env["omniauth.auth"]nil:

Today, I cannot authenticate, as I get nil for request.env["omniauth.auth"] after the API received the following piece of code:

@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)

请提出如何解决此问题的建议,或提供替代方法.

Please suggest how I can solve this issue, or provide an alternative to this.

推荐答案

最后,我以某种方式通过提供备用的OpenIdConnect端点来解决用户信息,从而设法解决了该问题.使用,我替换了:

Finally, I somehow managed to solve the issue by providing an alternate OpenIdConnect endpoint for user information. Using source, I replaced:

https://www.googleapis.com/plus/v1/people/me/openIdConnect

具有:

https://www.googleapis.com/oauth2/v3/userinfo

我用猴子修补了omniauth-google-oauth2,如下所示:

I monkey-patched omniauth-google-oauth2 as follows:

config/initializers/omniauth_google_oauth2_patch.rb

class OmniAuth::Strategies::GoogleOauth2 < OmniAuth::Strategies::OAuth2
  def raw_info
    @raw_info ||= access_token.get('https://www.googleapis.com/oauth2/v3/userinfo').parsed
  end
end

现在效果很好.

这篇关于Google加上API今天已关闭,可以使用哪种替代方式进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆