Google加上API今天关机,可以用什么办法来认证?
Google plus API shutdown today, which alternative can be used to authentication?
我正在使用 rails-4
,并在我的应用程序中使用 OAuth-2
与 Google+ API
进行身份验证,为此使用了以下 gem:
- omniauth-oauth2
- omniauth-google-oauth2
我收到了以下预先的电子邮件通知:
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
:
@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)
请建议我如何解决这个问题,或者提供替代方案。
最后,我以某种方式设法通过为用户信息提供备用 OpenIdConnect 端点来解决问题。使用 source,我替换了:
https://www.googleapis.com/plus/v1/people/me/openIdConnect
与:
https://www.googleapis.com/oauth2/v3/userinfo
我猴子修补 omniauth-google-oauth2
如下:
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
现在效果很好。
我正在使用 rails-4
,并在我的应用程序中使用 OAuth-2
与 Google+ API
进行身份验证,为此使用了以下 gem:
- omniauth-oauth2
- omniauth-google-oauth2
我收到了以下预先的电子邮件通知:
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
:
@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)
请建议我如何解决这个问题,或者提供替代方案。
最后,我以某种方式设法通过为用户信息提供备用 OpenIdConnect 端点来解决问题。使用 source,我替换了:
https://www.googleapis.com/plus/v1/people/me/openIdConnect
与:
https://www.googleapis.com/oauth2/v3/userinfo
我猴子修补 omniauth-google-oauth2
如下:
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
现在效果很好。