我需要做什么更改Google+ API,请和OAuth关机?

问题描述 投票:2回答:1

我收到了来自谷歌拥有此内容的电子邮件:

你好Google+开发,

下面的电子邮件包含您最近的Google+的API的使用。注意:它包括Google+的OAuth的范围请求,这也受到了Google+关机。发送到主动API调用者的现有邮件不包括有关的OAuth请求的信息。最后一个提醒邮件将在二月份被发送到谁仍然有活跃的API或OAuth的请求活动用户。

我需要什么知道吗?

在2019年3月7日,所有的Google+ API和Google+登录将被彻底关闭。这将是一个渐进的关机,以起步早,2019年1月28,间歇性地失败的API调用,并于Google+的OAuth请求范围开始,早在2019年2月15,间歇性地失败。

我需要做什么?

由2019年3月7日请更新下面列出的项目,并确保他们不再使用Google+ API或Google+的请求OAuth范围。下面的数据显示哪些Google+ API方法您的项目最近呼吁,以及Google+的OAuth范围已要求。

注意:如果你看到来电people.get,这些都可以在你的应用程序,这是现在完全停用,正在关闭使用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范围,但没有工作,所以这就是为什么我使用这两个范围。这里是一个片段,我是如何使用的:

我要求两个作用域,这里是它的片段:

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个回答
2
投票

问题不在于你用plus.profile范围,那就是库使用HTTP端点plus.people.get获取配置文件信息。即使你不使用plus范围,最佳实践三年前使用的加终端获取的个人资料信息。

有改变所使用的端点pull request。这是我不清楚为什么它没有被合并,但它应该是很快。

在此期间,您还可以在创建userProfileURL对象指定的GoogleStrategy属性配置端点。因此,该代码可能看起来像

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(这谷歌支持)获取配置文件信息。您可能希望切换到这一个,因为它似乎得到支持。

© www.soinside.com 2019 - 2024. All rights reserved.