5.0.1 • Published 4 years ago
@forbital/github-token v5.0.1
@forbital/github-token
Obtain GitHub Token from various location.
~/.config/hub~/.config/gh/config.ymlGH_TOKENGITHUB_TOKEN
Install
yarn add @forbital/github-token
# or npm i --save @forbital/github-tokenUse
CLI
echo $(github-token)or
eval $(github-token --shell)
# then
echo $GITHUB_TOKENor
echo "$(github-token --env)" >> .envdirenv
# .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);