-
Notifications
You must be signed in to change notification settings - Fork 942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Google login to FTW #1376
Add Google login to FTW #1376
Conversation
6b89b4d
to
0167d18
Compare
server/api/auth/loginWithIdp.js
Outdated
@@ -99,7 +99,9 @@ module.exports = (err, user, req, res, clientID, idpId) => { | |||
} | |||
} | |||
}) | |||
.catch(() => { | |||
.catch(err => { | |||
console.error(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of data the 'err' contains? Is there something that should not end up to logs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe all the console.logs in the server routes could be checked and potentially enforce the usage of log.js instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍. Only suggestion is to try the login once without the client secret and see if a) the login succeeds b) fetching user profile succeeds.
const PORT = parseInt(process.env.REACT_APP_DEV_API_SERVER_PORT, radix); | ||
const rootUrl = process.env.REACT_APP_CANONICAL_ROOT_URL; | ||
const clientID = process.env.REACT_APP_GOOGLE_CLIENT_ID; | ||
const clientSecret = process.env.GOOGLE_CLIENT_SECRET; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering what this is used for. The Google Web login reference does not mention using the client secret: https://developers.google.com/identity/sign-in/web/reference. Apparently this is used to fetch user profile info but shouldn't the access token suffice for that?
What if this is left out? Does fetching the profile fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this without clientSecret and it didn't work. At least the Passport.js expects that the client secret is there. After some investigation I think I found the answer from Google's docs: For example, a JavaScript application does not require a secret, but a web server application does.
It's a little confusing because we are also using JavaScript in the FTWs server. But anyway, when we don't use Google's JavaScript client directly for the web application but we are handling the authentication in the web server, we need to provide the client secret too.
…he handling in log in and create endpoints
…cebook related values
…and use it in button
0167d18
to
26350af
Compare
This PR adds Google login to FTW
It follows the same logic as Facebook login and uses the
createUserWithIdp
andloginWithIdp
endpoints which were added with Facebook login. You can find more information from Facebook login PR #1366