Skip to content

Commit

Permalink
More octokit stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed May 19, 2018
1 parent 5f7b548 commit c5755a2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions source/platforms/github/GitHubAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class GitHubAPI {
* I wouldn't have a problem with moving this to use this API under the hood
* but for now that's just a refactor someone can try.
*/
getExternalAPI = (JWTForGithubApp?: string): GitHubNodeAPI => {
getExternalAPI = (accessTokenForApp?: string): GitHubNodeAPI => {
const host = process.env["DANGER_GITHUB_API_BASE_URL"] || undefined
const options: GitHubNodeAPI.Options & { debug: boolean } = {
debug: !!process.env.LOG_FETCH_REQUESTS,
Expand All @@ -51,14 +51,12 @@ export class GitHubAPI {
...this.additionalHeaders,
},
}
// A token should have been set by this point
const token = accessTokenForApp || this.token!

const api = new GitHubNodeAPI(options)
api.authenticate({ type: "token", token: token })

if (JWTForGithubApp) {
// I sent a PR for this: https://github.com/octokit/rest.js/pull/873
api.authenticate({ type: "app", token: JWTForGithubApp } as any)
} else if (this.token) {
api.authenticate({ type: "token", token: this.token })
}
return api
}

Expand Down

0 comments on commit c5755a2

Please sign in to comment.