Creates a GitHub Octokit instance from any available auth token. ๐
npm install octokit-from-auth
Creates a GitHub Octokit instance from any available auth token.
๐
``shell`
npm i octokit-from-auth
Two functions are exported by the octokit-from-auth package.Octokit
Both are asynchronous and take in the same constructor parameters as the class:
- octokitFromAuth: rejects if an auth token isn't provided and can't be resolved by get-github-auth-tokenoctokitFromAuthSafe
- : resolves an Octokit with no authentication if an auth token isn't provided and can't be resolved by get-github-auth-token
Both return a new Octokit instance.
`ts
import { octokitFromAuth } from "octokit-from-auth";
// auth token used:
// process.env.GH_TOKEN ?? (await $gh auth token)`
await octokitFromAuth();
The Octokit's auth is retrieved with get-github-auth-token, which defaults to process.env.GH_TOKEN, or failing that, gh auth token.
If neither is available then an auth token must be provided as an option:
`ts
import { octokitFromAuth } from "octokit-from-auth";
// auth token used:
// "gho_..."
await octokitFromAuth({ auth: "gho_..." });
`
See .github/CONTRIBUTING.md, then .github/DEVELOPMENT.md.
Thanks! ๐
Josh Goldberg โจ ๐ป ๐ ๐ ๐ค ๐ ๐ง ๐ ๐ง |
> ๐ This package was templated with create-typescript-app` using the Bingo framework.