Oauth 2.0 我需要为谷歌改变什么;API和OAuth关闭?
我收到一封来自谷歌的电子邮件,内容如下: 你好,谷歌+开发者 下面的电子邮件包含您最近使用的Google+API。注意:它包括Google+OAuth范围请求,这些请求也会受到Google+关闭的影响。之前发送给活动API调用方的电子邮件中没有包含有关OAuth请求的信息。最后一封提醒电子邮件将在2月份发送给仍有活动API或OAuth请求活动的用户 我需要知道什么? 2019年3月7日,所有Google+API和Google+登录将完全关闭。这将是一次渐进式关闭,API调用最早在2019年1月28日开始间歇性失败,OAuth对Google+范围的请求最早在2019年2月15日开始间歇性失败 我需要做什么? 请在2019年3月7日之前更新下面列出的项目,并确保它们不再使用Google+API或请求Google+OAuth范围。下面的数据显示了您的项目最近调用了哪些Google+API方法,以及它请求的Google+OAuth范围 注意:如果您看到对people.get的调用,这些调用可能是在您的应用程序中使用Google+登录功能的结果,该功能现在已被完全弃用,正在关闭。开发者应该从Google+登录功能迁移到更全面的Google登录认证系统 我使用passport和这个来避免为用户存储密码。但我还需要电子邮件地址。我试图只使用Oauth 2.0 我需要为谷歌改变什么;API和OAuth关闭?,oauth-2.0,google-api,passport.js,google-plus,Oauth 2.0,Google Api,Passport.js,Google Plus,我收到一封来自谷歌的电子邮件,内容如下: 你好,谷歌+开发者 下面的电子邮件包含您最近使用的Google+API。注意:它包括Google+OAuth范围请求,这些请求也会受到Google+关闭的影响。之前发送给活动API调用方的电子邮件中没有包含有关OAuth请求的信息。最后一封提醒电子邮件将在2月份发送给仍有活动API或OAuth请求活动的用户 我需要知道什么? 2019年3月7日,所有Google+API和Google+登录将完全关闭。这将是一次渐进式关闭,API调用最早在2019年1月2
电子邮件
作用域,但这不起作用,所以我同时使用这两个作用域。下面是一个片段,我是如何使用它的:
我请求两个作用域,下面是它的代码段:
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
scope。
即使在这方面,他们也建议使用
profile
和email
。那么我为什么要收到电子邮件呢?问题不在于您使用了plus.profile
范围,而是库使用了plus.people.get
的HTTP端点来获取配置文件信息。即使您没有使用plus
范围,三年前的最佳实践是使用plus端点来获取概要信息
存在一个更改所使用端点的方法。我不清楚为什么它没有被合并,但应该很快就会合并
同时,在创建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
});
}));
还有一种方法使用OpenID(谷歌支持)来获取个人资料信息。您可能希望切换到此选项,因为它似乎受支持
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
});
}));