npm.io
0.3.2 • Published 1 year ago

octokit-from-auth

Licence
MIT
Version
0.3.2
Deps
2
Size
9 kB
Vulns
0
Weekly
0
Stars
2

Octokit From Auth

Creates a GitHub Octokit instance from any available auth token.

 All Contributors: 1  Code of Conduct: Kept  Coverage  License: MIT  npm version  TypeScript: Strict

Usage

npm i octokit-from-auth

Two functions are exported by the octokit-from-auth package. Both are asynchronous and take in the same constructor parameters as the Octokit class:

  • octokitFromAuth: rejects if an auth token isn't provided and can't be resolved by get-github-auth-token
  • octokitFromAuthSafe: 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.

import { octokitFromAuth } from "octokit-from-auth";

// auth token used:
// process.env.GH_TOKEN ?? (await 

Octokit From Auth

Creates a GitHub Octokit instance from any available auth token.

 All Contributors: 1  Code of Conduct: Kept  Coverage  License: MIT  npm version  TypeScript: Strict

Usage

npm i octokit-from-auth

Two functions are exported by the __INLINE_CODE_0__ package. Both are asynchronous and take in the same constructor parameters as the __INLINE_CODE_1__ class:

  • __INLINE_CODE_2__: rejects if an auth token isn't provided and can't be resolved by __INLINE_CODE_3__
  • __INLINE_CODE_4__: resolves an __INLINE_CODE_5__ with no authentication if an auth token isn't provided and can't be resolved by __INLINE_CODE_6__

Both return a new Octokit instance.

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:

import { octokitFromAuth } from "octokit-from-auth";

// auth token used:
// "gho_..."
await octokitFromAuth({ auth: "gho_..." });

Development

See .github/CONTRIBUTING.md, then .github/DEVELOPMENT.md. Thanks!

Contributors

Josh Goldberg
Josh Goldberg

This package was templated with create-typescript-app using the Bingo framework.