jaredhanson / jaredhanson/passport-github
'access_token' not present in the passport-github2 request
- Dominant language
- JavaScript
- Stars
- 535
- Forks
- 290
- PR merge metrics
- No merged PRs in 30d
Description
I have registered an OAuth App via my Github account. I am basically trying to authorize my node requests(by sending `access_token` as part of request cookies) so I can access few APIs on another server. Hence I am using the `github-passport2` package. I have setup the github strategy etc. & it seems to be all according to the doc. The flow works well too.
### My Issue
After logging into Github(authorized) & getting redirected back to my `/auth/github/callback`, I ideally should be authorized and should have an `access_token` in the `req`. But I don't have it! Because of this I am not able to authorize my future requests with an `access_token`.
Important to note is that, this `access_token` is automatically attached when the request is initiated from a browser/client(using `withCredentials: true` parameter). The same `access_token` via node doesn't seem to be retrievable.
```
passport.use(new GitHubStrategy({
clientID: GITHUB_CLIENT_ID,
clientSecret: GITHUB_CLIENT_SECRET,
callbackURL: "http://localhost:8080/auth/github/callback",
},
function(accessToken, refreshToken, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
return done(null, profile);
});
}
));
app.get('/auth/github', passport.authenticate('github', { scope: [ 'user:email' ] }), function(req, res){
// The request will be redirected to GitHub for authentication, so this
// function will not be called.
});
app.get('/auth/github/callback', passport.authenticate('github', { failureRedirect: '/login' }), function(req, res) {
console.log(req); // <- This ideally should have the access_token? but doesn't
});
```
Any help is much appreciated
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the GitHubStrategy setup and the /auth/github/callback handler shown in the issue, then inspect how the verification callback receives and exposes authentication values. Compare that flow with the Passport and strategy documentation; done means the issue clearly identifies where the token is available or what configuration is missing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100