Today I need an access token for github so that I could commit show transcripts for Syntax via some automated scripts.
Has three options:
The first two give full access to all your repos - public and private. Kinda scary.
So I went the apps route. An app can be scoped to a repo with very fine grain access controls. Most of my time was spent looking for URLs and asking for helpful packages on twitter.
Here is how to to do it quickly:
npm init
, and then npm install github-app-installation-token
. This is handy package to do it all quickly.get-ya-token.js
file like this:const { getToken } = require('github-app-installation-token');
async function go() {
const res = await getToken({
appId: 'from-earlier',
installationId: 'from-earlier',
privateKey: `Paste the contents of your private key in here. Use backticks because it's multi-line`,
});
console.log(res); // your token will be here
}
go();
node get-ya-token.js
That should spit out a token.
Hope it helps.
Find an issue with this post? Think you could clarify, update or add something?
All my posts are available to edit on Github. Any fix, little or small, is appreciated!