UNPKG

1.31 kBTypeScriptView Raw
1import type { Logger } from "pino";
2import { ProbotOctokit } from "./octokit/probot-octokit";
3import { State } from "./types";
4/**
5 * Authenticate and get a GitHub client that can be used to make API calls.
6 *
7 * You'll probably want to use `context.octokit` instead.
8 *
9 * **Note**: `app.auth` is asynchronous, so it needs to be prefixed with a
10 * [`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await)
11 * to wait for the magic to happen.
12 *
13 * ```js
14 * module.exports = ({ app }) => {
15 * app.on('issues.opened', async context => {
16 * const octokit = await app.auth();
17 * });
18 * };
19 * ```
20 *
21 * @param id - ID of the installation, which can be extracted from
22 * `context.payload.installation.id`. If called without this parameter, the
23 * 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)
24 * instead of as a specific installation, which means it can only be used for
25 * [app APIs](https://developer.github.com/v3/apps/).
26 *
27 * @returns An authenticated GitHub API client
28 */
29export declare function auth(state: State, installationId?: number, log?: Logger): Promise<InstanceType<typeof ProbotOctokit>>;