passport-token-google's People
Forkers
grenadianbuzz coindream yogiis98 svindler katastreet sonhaichu razvancristian rgjamkhedkar devearos pranjal1127passport-token-google's Issues
access_token is not honored in the google cloud app engine
The id field of profile returned is undefined
According to google developer guide:
https://developers.google.com/identity/sign-in/web/backend-auth
The id is returned in the payload as sub. A small fix is needed in strategy.js as
profile.id = json.id || json.sub;
GoogleTokenStrategy.prototype.userprofile becomes something like
GoogleTokenStrategy.prototype.userProfile = function(accessToken, done) {
var profileUrl = 'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token='+accessToken;
this._oauth2.get(profileUrl, null, function (err, body, res) {
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }
try {
var json = JSON.parse(body);
var profile = { provider: 'google' };
profile.id = json.id || json.sub;
profile.displayName = json.name;
profile.name = { familyName: json.family_name,
givenName: json.given_name };
profile.emails = [{ value: json.email }];
profile._raw = body;
profile._json = json;
done(null, profile);
} catch(e) {
done(e);
}
});
}
Sent a pull request for the fix.
Issue with profileUrl
Hello, i spent some time debugging why this wasn't working and I found out that this line:
var profileUrl = 'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token='+accessToken;
should actually be
var profileUrl = 'https://www.googleapis.com/oauth2/v3/tokeninfo?access_token='+accessToken;
Maybe the google api has changed? Id token does nothing and it fails with an unauthorized code.
Edit: Actually, I confused the id_token with the access_token. The module expects an id_token apparently. You should update the documentation to specify that the id_token should be used or use the https://www.googleapis.com/oauth2/v3/userinfo?access_token= url.
profileUrl incorrectly has a query parameter of id_token
According to the readme, any requests to authenticate require a access_token parameter. However, the profileUrl has a parameter of id_token. Passing in an access token does not work.
CodeRef:
GoogleTokenStrategy.prototype.userProfile = function(accessToken, done) { var profileUrl = 'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token='+accessToken; this._oauth2.get(profileUrl, null, function (err, body, res) {...
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.