5.0.1 • Published 3 years ago

@forbital/github-token v5.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

@forbital/github-token

npm-version npm-downloads

Obtain GitHub Token from various location.

  1. ~/.config/hub
  2. ~/.config/gh/config.yml
  3. GH_TOKEN
  4. GITHUB_TOKEN

Install

yarn add @forbital/github-token
# or npm i --save @forbital/github-token

Use

CLI

echo $(github-token)

or

eval $(github-token --shell)
# then
echo $GITHUB_TOKEN

or

echo "$(github-token --env)" >> .env

direnv

# .envrc
eval $(github-token --shell)

Node.js

import getToken from "@forbital/github-token";

const user = await fetch("https://api.github.com/user", {
  headers: { Authorization: `Bearer ${getToken()}` },
}).then((res) => res.json());

console.log(user.twitter_username);
5.0.1

3 years ago

5.0.0

3 years ago

4.0.0

4 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago