question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How is the req object passed to Google callback?

See original GitHub issue

I’ve only taken snippets of code from this repo for my project, but in

https://github.com/reactGo/reactGo/blob/master/server/db/sequelize/passport/google.js

for the Google OAuth2 strategy you can see there is a request object in the parameters: export default (req, accessToken, refreshToken, profile, done) => {...}

I couldn’t find where this was set or passed from. It must be somewhere in the middleware right? I was able to have access to the object after setting a passReqToCallback to be true here so it looks something like:

  passport.use(new GoogleStrategy({
    clientID: google.clientID,
    clientSecret: google.clientSecret,
    passReqToCallback: true,
    callbackURL: google.callbackURL
  }, handleGoogleUserInfo));

. Perhaps there can be some explanation on this in the docs or comments since this req object isn’t talked about in the raw Passport setup instructions? Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ZeroChocommented, Aug 16, 2016

Thank you. @gsccheng I also think it needs passReqToCallback: true. I’ll make PR.

1reaction
ZeroChocommented, Aug 18, 2016

@gsccheng thank you for reporting. It is merged

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passport JS Google oauth20 callback missing req object
I have seen some similar questions here but the answer is irrelevant to mine, as I have declared passReqToCallback.
Read more >
Add and delete callbacks | Generic pass - Google Developers
For every add or delete performed by the user on an object, Google makes callbacks to the merchants with details about the add...
Read more >
HTTPS | Node.js v19.3.0 Documentation
https.request(url[, options][, callback]) # ; v10.9.0. The url parameter can now be passed along with a separate options object. ; v9.3.0. The options...
Read more >
5.x API - Express.js
A new body object containing the parsed data is populated on the request object after the middleware ... The parent app is passed...
Read more >
10. Node.js: HTTP, HTTPS - Books at mixu.net
The first parameter of the request handler callback is a ServerRequest object. ServerRequests are Readable Streams, so we can bind to the "data"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found