Skip to content

Commit b3fad76

Browse files
Move auth token to header instead of query param (#160)
Github will deprecate auth via query param, so we move this to http header. Closes #121.
1 parent a964e5b commit b3fad76

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

download.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ function downloadPrebuild (downloadUrl, opts, cb) {
4343
var reqOpts = proxy({ url: downloadUrl }, opts)
4444

4545
if (opts.token) {
46-
reqOpts.url += '?access_token=' + opts.token
4746
reqOpts.headers = {
4847
'User-Agent': 'simple-get',
49-
Accept: 'application/octet-stream'
48+
Accept: 'application/octet-stream',
49+
Authorization: 'token ' + opts.token
5050
}
5151
}
5252

test/asset-test.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ nock('https://api.github.com:443', {
3333
})
3434
.persist()
3535
.get(function (uri) {
36-
return /\/repos\/ralphtheninja\/a-native-module\/releases\/assets\/\d*\?access_token=TOKEN/g.test(uri)
36+
return /\/repos\/ralphtheninja\/a-native-module\/releases\/assets\/\d*/g.test(uri)
3737
})
3838
.reply(302, undefined, {
3939
Location: function (req, res, body) {
4040
var assetId = req.path
4141
.replace('/repos/ralphtheninja/a-native-module/releases/assets/', '')
42-
.replace('?access_token=TOKEN', '')
4342

4443
for (var release of releases) {
4544
for (var asset of release.assets) {
@@ -85,7 +84,7 @@ test('downloading from GitHub with token', function (t) {
8584
var _request = https.request
8685
https.request = function (req) {
8786
https.request = _request
88-
t.equal('https://' + req.hostname + req.path, downloadUrl + '?access_token=' + opts.token, 'correct url')
87+
t.equal('https://' + req.hostname + req.path, downloadUrl, 'correct url')
8988
return _request.apply(https, arguments)
9089
}
9190

0 commit comments

Comments
 (0)