1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.auth = void 0;
|
4 | const get_authenticated_octokit_1 = require("./octokit/get-authenticated-octokit");
|
5 | /**
|
6 | * Authenticate and get a GitHub client that can be used to make API calls.
|
7 | *
|
8 | * You'll probably want to use `context.octokit` instead.
|
9 | *
|
10 | * **Note**: `app.auth` is asynchronous, so it needs to be prefixed with a
|
11 | * [`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await)
|
12 | * to wait for the magic to happen.
|
13 | *
|
14 | * ```js
|
15 | * module.exports = ({ app }) => {
|
16 | * app.on('issues.opened', async context => {
|
17 | * const octokit = await app.auth();
|
18 | * });
|
19 | * };
|
20 | * ```
|
21 | *
|
22 | * @param id - ID of the installation, which can be extracted from
|
23 | * `context.payload.installation.id`. If called without this parameter, the
|
24 | * client wil authenticate [as the app](https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/about-authentication-options-for-github-apps/#authenticating-as-a-github-app)
|
25 | * instead of as a specific installation, which means it can only be used for
|
26 | * [app APIs](https://developer.github.com/v3/apps/).
|
27 | *
|
28 | * @returns An authenticated GitHub API client
|
29 | */
|
30 | async function auth(state, installationId, log) {
|
31 | return get_authenticated_octokit_1.getAuthenticatedOctokit(Object.assign({}, state, log ? { log } : null), installationId);
|
32 | }
|
33 | exports.auth = auth;
|
34 | //# sourceMappingURL=auth.js.map |
\ | No newline at end of file |