npm.io
0.2.0 • Published 1 month ago

get-github-auth-token

Licence
MIT
Version
0.2.0
Deps
0
Size
9 kB
Vulns
0
Weekly
0
Stars
6

get-github-auth-token

Retrieves the running user's GitHub authentication token.

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

Usage

npm i get-github-auth-token
import { getGitHubAuthToken } from "get-github-auth-token";

const auth = await getGitHubAuthToken("Hello, world! 💖");

if (auth.succeeded) {
	console.log("Token:", auth.token);
} else {
	console.error("Oh no:", auth.error);
}

getGitHubAuthToken attempts to find a GitHub auth token from the following places, in order:

  1. process.env.GH_TOKEN
  2. process.env.GITHUB_TOKEN
  3. Executing gh auth token as a child process

Using this to create a new Octokit instance? See JoshuaKGoldberg/octokit-from-auth.

Development

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

Contributors

Josh Goldberg
Josh Goldberg

uncenter
uncenter

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