Passport.js 中的 Google 策略是否在 Google+ 结束时弃用

Is the Google Strategy in Passport.js deprecated with the end of Google+

我在我的 nodejs 应用程序中使用 Passport.js 和 passport-google-oauth20 来使用 "Google Strategy" 进行身份验证。 我刚刚收到一封来自 Google 的电子邮件,表明我使用 Google+ API 中的 "plus.people.get" 并且它将被弃用。 我应该改变什么吗?我不直接使用这个 API 调用,但也许 Passport 可以?

是的,Passport 的 Google OAuth 策略当前使用 Google+ API 端点来检索用户的个人资料信息。

如果您在 https://console.developers.google.com/apis/dashboard 上从 Google 控制台禁用 Google+ API 集成,则使用 Google 登录将不适用于您的应用。从 Google 收到的错误包含此消息:

GooglePlusAPIError: Access Not Configured. Google+ API has not been used in project xxxxxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/plus.googleapis.com/overview?project=xxxxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

为了使您的应用程序在禁用 Google+ API 的情况下正常工作,您必须使用此策略选项:

userProfileURL: 'https://www.googleapis.com/oauth2/v3/userinfo'
就像在这个例子中:
var GoogleStrategy = require('passport-google-oauth20').Strategy;

passport.use(new GoogleStrategy({
    clientID: GOOGLE_CLIENT_ID,
    clientSecret: GOOGLE_CLIENT_SECRET,
    callbackURL: "http://www.example.com/auth/google/callback",
    userProfileURL: 'https://www.googleapis.com/oauth2/v3/userinfo'
  },
  function(accessToken, refreshToken, profile, cb) {
           ...
  }
));