forked from mirrors/probot
robot.auth as integration or installation
This commit is contained in:
parent
dbc48c14f5
commit
5d8e229353
21
lib/robot.js
21
lib/robot.js
|
@ -28,13 +28,20 @@ class Robot {
|
||||||
}
|
}
|
||||||
|
|
||||||
async auth(id) {
|
async auth(id) {
|
||||||
const token = await this.cache.wrap(`integration:${id}:token`, () => {
|
let github;
|
||||||
this.log.info(`creating token for installation ${id}`);
|
|
||||||
return this.integration.createToken(id);
|
if(id) {
|
||||||
}, {ttl: 60 * 60});
|
const token = await this.cache.wrap(`integration:${id}:token`, () => {
|
||||||
|
this.log.info(`creating token for installation ${id}`);
|
||||||
|
return this.integration.createToken(id);
|
||||||
|
}, {ttl: 60 * 60});
|
||||||
|
|
||||||
|
github = new GitHubApi({debug: process.env.LOG_LEVEL === 'trace'});
|
||||||
|
github.authenticate({type: 'token', token: token.token});
|
||||||
|
} else {
|
||||||
|
github = await this.integration.asIntegration();
|
||||||
|
}
|
||||||
|
|
||||||
const github = new GitHubApi({debug: process.env.LOG_LEVEL === 'trace'});
|
|
||||||
github.authenticate({type: 'token', token: token.token});
|
|
||||||
return probotEnhancedClient(github);
|
return probotEnhancedClient(github);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +53,7 @@ class Robot {
|
||||||
function probotEnhancedClient(github) {
|
function probotEnhancedClient(github) {
|
||||||
github = rateLimitedClient(github);
|
github = rateLimitedClient(github);
|
||||||
|
|
||||||
github.paginate = require('./lib/paginate');
|
github.paginate = require('./paginate');
|
||||||
|
|
||||||
return github;
|
return github;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue