Retrieves the running user's GitHub authentication token. πͺ
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:
process.env.GH_TOKEN
- Executing
gh auth token
as a child process
Josh Goldberg β¨ π» π π π€ π π§ π π§ |
π This package was templated with
create-typescript-app
.