mstade / passport-google-oauth2 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from iliakan/passport-google-oauth
Google (OAuth 2.0) authentication strategy for Passport and Node.js.
License: MIT License
This project forked from iliakan/passport-google-oauth
Google (OAuth 2.0) authentication strategy for Passport and Node.js.
License: MIT License
this is my implementation and everything that I tried it will not return the gender and birthday as indicated in the documentation
GOOGLE_FIELDS='id,birthday,email,gender,family_name,given_name,locale,picture,profile'
GOOGLE_SCOPE='profile,email,openid,https://www.googleapis.com/auth/user.birthday.read,https://www.googleapis.com/auth/user.gender.read'
passport.use(new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENTID,
clientSecret: process.env.GOOGLE_SECRET,
callbackURL: process.env.GOOGLE_CALLBACK,
profileFields: process.env.GOOGLE_FIELDS.split(','),
passReqToCallback: true,
enableProof: true,
},
(async (req, token, tokenSecret, profile, next) => {
try {
const addedParam = JSON.parse(req.query.state);
const action = addedParam.action || 'l';
const memberType = addedParam.member;
const {
id,
family_name,
given_name,
email,
gender, // always null
birthday, // always null
picture,
} = profile;
am I doing something wrong or is this not implemented in this strategy, as I understand to get these fields from google documentation you need to make a call to the people api like so: https://people.googleapis.com/v1/people/me?personFields=genders,birthdays
Hello,
I followed the steps given but as soon as i click on "Allow" after logging into my google account, it breaks with the below error:-
Error
at D:\ASU\SER 517\Oauth_mstade\passport-google-oauth2\example\node_modules\passport-google-oauth2\lib\oauth2.js:92:28
at passBackControl (D:\ASU\SER 517\Oauth_mstade\passport-google-oauth2\example\node_modules\oauth\lib\oauth2.js:132:9)
at IncomingMessage. (D:\ASU\SER 517\Oauth_mstade\passport-google-oauth2\example\node_modules\oauth\lib\oauth2.js:157:7)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1059:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Any idea whats going wrong here.
Thanks,
Abhishek Dutta
I am using strong-cluster-connect-store and strong-cluster-control npm modules to create an Express Cluster with Cross Cluster Session Storage.
So I have setup a LocalStrategy and a GoogleStrategy setup. And the LocalStrategy seems to be fine.
Once logged in on one worker, the others know of that session as well. However, when using the GoogleStrategy I only seem to be Authenticated for that worker.
My feeling is it is today with the store that is being used, internally. But I could be very much mistaken.
Any ideas/tips/tricks would be greatly appreciated.
Hi!
I am not able to access the refreshToken inside the 'new Strategy' callback function.
When logging in it does ask for offline access, and everything works, except for accessing the refreshtoken.
Google+ API is shutting down on March 9, 2019. The progressive shutdown begins as early as January!
I have no callback url, I want to just pass token and get user data. Is it possible?
I make a small mod to show coverPhoto in profile information #9
I run this code and I login with Google, but no user is stored in req, so when it redirects back to the index page, it still shows "Login" and NOT "account". Why/How can this be?
I put a breakpoint in my "function (request, accessToken, refreshToken, profile, done) {" and it shows profile is filled with data and so I "return done(null, profile)", but I can't access profile or user anywhere else
@natanbr yes, here what I'm currently doing:
const passportGoogle = require('passport-google-oauth').OAuth2Strategy;
const computeConnectedUser = strategy => (req, accessToken, refreshToken, profile, done) => done(false, { strategy, accessToken, refreshToken, ...profile });
const googleStrategy = new passportGoogle({
clientID: googleConfig.clientID,
clientSecret: googleConfig.clientSecret,
callbackURL: googleConfig.callbackURL,
profileFields: googleConfig.profileFields,
passReqToCallback: true,
}, computeConnectedUser('google'));
passport.use(googleStrategy);
router.all(googleConfig.connectURL, passport.authenticate('google', { authType: 'rerequest', accessType: 'offline', prompt: 'consent', includeGrantedScopes: true, scope: googleConfig.scope }));
router.all(googleConfig.callbackURL, passport.authenticate('google', { failureRedirect: googleConfig.connectURL, session: false }), oauthed);
Originally posted by @damianobarbati in #5 (comment)
Hello, I am facing following issue with all the passport-oauth2 can someone please help
I'm not sure if it's intentional or not but the fact that the package version is 0.y.z means that any change is considered a major semver change (https://semver.org/#spec-item-4) which interferes with automatic dependency management tools (like npm update
) which tend to strictly follow semver. If you consider this package stable, please consider incrementing to version 1!
I tried to find the way to fix this and still no clue. I want to know what's going on
please help me
thank you
Error
at C:\Users\Admin-PC\Documents\Ecommerce-Cores\authentication\node_modules\passport-google-oauth2\lib\oauth2.js:92:28
at passBackControl (C:\Users\Admin-PC\Documents\Ecommerce-Cores\authentication\node_modules\oauth\lib\oauth2.js:132:9)
at IncomingMessage. (C:\Users\Admin-PC\Documents\Ecommerce-Cores\authentication\node_modules\oauth\lib\oauth2.js:157:7)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.