@forbital/github-token
v5.0.1
Published
Obtain GitHub Token from various location.
Downloads
18
Readme
@forbital/github-token
Obtain GitHub Token from various location.
~/.config/hub
~/.config/gh/config.yml
GH_TOKEN
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);