Skip to content

Commit

Permalink
Move auth token to header instead of query param (#160)
Browse files Browse the repository at this point in the history
Github will deprecate auth via query param, so we move this to http
header. Closes #121.
  • Loading branch information
nicolai-nordic authored Aug 11, 2021
1 parent a964e5b commit b3fad76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions download.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ function downloadPrebuild (downloadUrl, opts, cb) {
var reqOpts = proxy({ url: downloadUrl }, opts)

if (opts.token) {
reqOpts.url += '?access_token=' + opts.token
reqOpts.headers = {
'User-Agent': 'simple-get',
Accept: 'application/octet-stream'
Accept: 'application/octet-stream',
Authorization: 'token ' + opts.token
}
}

Expand Down
5 changes: 2 additions & 3 deletions test/asset-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ nock('https://api.github.com:443', {
})
.persist()
.get(function (uri) {
return /\/repos\/ralphtheninja\/a-native-module\/releases\/assets\/\d*\?access_token=TOKEN/g.test(uri)
return /\/repos\/ralphtheninja\/a-native-module\/releases\/assets\/\d*/g.test(uri)
})
.reply(302, undefined, {
Location: function (req, res, body) {
var assetId = req.path
.replace('/repos/ralphtheninja/a-native-module/releases/assets/', '')
.replace('?access_token=TOKEN', '')

for (var release of releases) {
for (var asset of release.assets) {
Expand Down Expand Up @@ -85,7 +84,7 @@ test('downloading from GitHub with token', function (t) {
var _request = https.request
https.request = function (req) {
https.request = _request
t.equal('https://' + req.hostname + req.path, downloadUrl + '?access_token=' + opts.token, 'correct url')
t.equal('https://' + req.hostname + req.path, downloadUrl, 'correct url')
return _request.apply(https, arguments)
}

Expand Down

0 comments on commit b3fad76

Please sign in to comment.