jaredhanson / jaredhanson/passport-github

Access token as query parameter is deprecated (cannot fetch emails)

Open
#85 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
535
Forks
290
PR merge metrics
No merged PRs in 30d

Description

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used [patch-package](https://github.com/ds300/patch-package) to patch `passport-github@1.1.0` for the project I'm working on.

GitHub has deprecated passing the access token as a query param and it should now be passed in the Authentication field of the headers. (https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/)

Here is the diff that solved my problem:

```diff
diff --git a/node_modules/passport-github/lib/strategy.js b/node_modules/passport-github/lib/strategy.js
index 0f4b07f..b036650 100644
--- a/node_modules/passport-github/lib/strategy.js
+++ b/node_modules/passport-github/lib/strategy.js
@@ -135,7 +135,8 @@ Strategy.prototype.userProfile = function(accessToken, done) {


if (self._scope && self._scope.indexOf('user:email') !== -1) {
- self._oauth2._request('GET', self._userProfileURL + '/emails', { 'Accept': 'application/vnd.github.v3+json' }, '', accessToken, function(err, body, res) {
+ self._oauth2.useAuthorizationHeaderforGET(true)
+ self._oauth2.get(self._userProfileURL + '/emails', accessToken, function(err, body, res) {
if (err) {
// If the attempt to fetch email addresses fails, return the profile
// information that was obtained.
```

This issue body was [partially generated by patch-package](https://github.com/ds300/patch-package/issues/296).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in node_modules/passport-github/lib/strategy.js at the userProfile email-fetching branch shown in the issue. Check how the GitHub /emails request currently passes the access token, then verify the request uses the Authentication header instead of a query parameter. Done means fetching emails works with GitHub's current authentication requirement.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, javascript, node.js
Domain
api, authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.