【问题标题】:What do I need to change for Google+ APIs and OAuth shutdown?对于 Google+ API 和 OAuth 关闭,我需要进行哪些更改?
【发布时间】:2019-02-10 10:47:17
【问题描述】:

我收到了一封来自 Google 的电子邮件,其中包含以下内容:

您好 Google+ 开发者,

以下电子邮件包含您最近对 Google+ API 的使用情况。注意:它包括 Google+ OAuth 范围请求,这些请求也会受到 Google+ 关闭的影响。之前发送给活动 API 调用者的电子邮件不包含有关 OAuth 请求的信息。最后一封提醒电子邮件将在 2 月发送给仍有活跃 API 或 OAuth 请求活动的用户。

我需要知道什么?

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

我需要做什么?

请在 2019 年 3 月 7 日之前更新您的下列项目,并确保它们不再使用 Google+ API 或请求 Google+ OAuth 范围。下面的数据显示了您的项目最近调用了哪些 Google+ API 方法,以及它请求的 Google+ OAuth 范围。

注意:如果您看到对 people.get 的调用,这可能是由于在您的应用程序中使用 Google+ 登录功能造成的,该功能现已完全弃用并正在关闭。开发者应该从 Google+ 登录功能迁移到更全面的 Google 登录身份验证系统。

| Project   | Google+ API Name  | Version | Method or OAuth ScopeA |   
|   A       | plus              | v1      | plus.people.get        |
|   B       | plus              | v1      | plus.people.get        |

我正在使用护照和plugin for google 来避免为用户存储密码。但我也需要电子邮件地址。我尝试只使用email 范围,但这不起作用,所以这就是我同时使用这两个范围的原因。这是一个sn-p,我是如何使用它的:

我请求两个范围,这里是它的 sn-p:

const express = require('express');
const passport = require('passport');
const GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;

const app = exprress();
auth(passport);
app.use(passport.initialize());
const auth = function (passport) = {
    passport.serializeUser((user, done) => {
        done(null, user);
    });
    passport.deserializeUser((user, done) => {
        done(null, user);
    });
    passport.use(new GoogleStrategy({
            clientID: CLIENT_ID,
            clientSecret: CLIENT_SECRET,
            callbackURL: CALLBACK_URL
        },
        (token, refreshToken, profile, done) => {
            return done(null, {
                profile: profile,
                token: token
            });
        }));
};
app.get('/auth/google', passport.authenticate('google', {
    scope: ['profile', 'email']
}));

所以现在我有点困惑,因为我不使用plus.people.get 范围。 即使在这个documentation page 上,他们也建议使用profileemail。那为什么我会收到电子邮件?

【问题讨论】:

    标签: oauth-2.0 google-api passport.js google-plus


    【解决方案1】:

    问题不在于您使用plus.profile 范围,而在于该库使用plus.people.get 的HTTP 端点 来获取配置文件信息。即使您没有使用 plus 范围,三年前的最佳做法是使用 plus 端点来获取配置文件信息。

    有一个pull request 可以更改所使用的端点。我不清楚为什么它没有被合并,但应该很快就会合并。

    同时,您还可以在创建GoogleStrategy 对象时在userProfileURL 属性中指定端点用于配置。所以该代码可能看起来像

    passport.use(new GoogleStrategy({
            clientID: CLIENT_ID,
            clientSecret: CLIENT_SECRET,
            callbackURL: CALLBACK_URL,
            userProfileURL: 'https://www.googleapis.com/oauth2/v3/userinfo'
        },
        (token, refreshToken, profile, done) => {
            return done(null, {
                profile: profile,
                token: token
            });
        }));
    

    还有another module 使用 OpenID(Google 支持)来获取个人资料信息。您可能希望切换到这个,因为它似乎受支持。

    【讨论】:

      猜你喜欢
      • 2013-04-27
      • 2017-05-02
      • 1970-01-01
      • 2018-08-19
      • 1970-01-01
      • 2013-02-13
      • 1970-01-01
      • 1970-01-01
      • 2017-03-15
      相关资源
      最近更新 更多