Switched to using token authentication for GitHub

no issue
This commit is contained in:
Daniel Lockyer 2020-04-01 12:00:19 +01:00
parent eb7e7a8f31
commit ff4d8ef903
3 changed files with 5 additions and 8 deletions

View File

@ -11,7 +11,6 @@ module.exports.create = (options = {}) => {
'gistName',
'gistDescription',
'github',
'github.username',
'github.token',
'userAgent'
);
@ -27,7 +26,7 @@ module.exports.create = (options = {}) => {
content: content.toString('utf8')
};
const auth = 'Basic ' + new Buffer(options.github.username + ':' + options.github.token).toString('base64');
const auth = 'token ' + options.github.token;
const reqOptions = {
uri: 'https://api.github.com/gists',

View File

@ -40,7 +40,6 @@ module.exports.create = (options = {}) => {
localUtils.checkMissingOptions(options,
'changelogPath',
'github',
'github.username',
'github.token',
'userAgent',
'uri',
@ -77,7 +76,7 @@ module.exports.create = (options = {}) => {
body.push('You can see the [full change log](' + options.gistUrl + ') for the details of every change included in this release.');
}
const auth = 'Basic ' + new Buffer(options.github.username + ':' + options.github.token).toString('base64');
const auth = 'token ' + options.github.token;
const reqOptions = {
uri: options.uri,
@ -112,13 +111,12 @@ module.exports.uploadZip = (options = {}) => {
localUtils.checkMissingOptions(options,
'zipPath',
'github',
'github.username',
'github.token',
'userAgent',
'uri'
);
const auth = 'Basic ' + new Buffer(options.github.username + ':' + options.github.token).toString('base64');
const auth = 'token ' + options.github.token;
const stats = fs.statSync(options.zipPath);
const reqOptions = {

View File

@ -10,7 +10,7 @@ describe('Releases', function () {
try {
lib.releases.uploadZip();
} catch (err) {
err.message.should.eql('Missing options: zipPath, github, github.username, github.token, userAgent, uri');
err.message.should.eql('Missing options: zipPath, github, github.token, userAgent, uri');
return done();
}
@ -19,7 +19,7 @@ describe('Releases', function () {
it('missing options', function (done) {
try {
lib.releases.uploadZip({zipPath: 'test', github: {username: 'test'}});
lib.releases.uploadZip({zipPath: 'test', github: {}});
} catch (err) {
err.message.should.eql('Missing options: github.token, userAgent, uri');
return done();