fix(dev-infra): github oauth token not picked up by Octokit (#42456)

We recently updated `@octokit/rest` to a more recent version. For this
the Github client had to be refactored to account for new types of
Octokit. With the refactorings the authentication of the Github
client broke as we used an incorrect option for setting the OAuth
token. The TS transpilation did not fail because the Octokit types
support arbitrary options in the constructor. This is not solvable
on our side, so we cannot prevent similar issues in the future
unfortunately. Adding tests for authentication is not a reasonable
option either.
This commit is contained in:
Paul Gschwendtner 2021-06-02 21:48:51 +02:00 committed by GitHub
parent 7bd5ea4a7e
commit 3b434ed94d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -240,7 +240,7 @@ var GithubClient = /** @class */ (function () {
/** The graphql instance with authentication set during construction. */
this._graphql = graphql.graphql.defaults({ headers: { authorization: "token " + this.token } });
/** The Octokit instance actually performing API requests. */
this._octokit = new rest.Octokit({ token: this.token });
this._octokit = new rest.Octokit({ auth: this.token });
this.pulls = this._octokit.pulls;
this.repos = this._octokit.repos;
this.issues = this._octokit.issues;

View File

@ -45,7 +45,7 @@ export class GithubClient {
/** The graphql instance with authentication set during construction. */
private _graphql = graphql.defaults({headers: {authorization: `token ${this.token}`}});
/** The Octokit instance actually performing API requests. */
private _octokit = new Octokit({token: this.token});
private _octokit = new Octokit({auth: this.token});
/**
* @param token The github authentication token for Github Rest and Graphql API requests.