1.1.3 • Published 7 years ago
@ahmadnassri/github-cli-auth v1.1.3
GitHub Auth CLI Helper
Helper utility for cli authentication flow with GitHub
Creates and manages Personal Access Tokens, prompting the user for username, password, 2FA as needed, while using the system's keychain to store secrets.
Install
npm install @ahmadnassri/github-cli-authOS Support
| OS | Secret Manager | Setup Needed |
|---|---|---|
| macOS | Keychain | ✗ |
| Windows | Credential Vault | ✗ |
| Linux | Secret Service API Draft / libsecret | ✓ |
Linux Setup: Install
libsecretbefore runningnpm install:
- Debian/Ubuntu:
sudo apt-get install libsecret-1-dev- Red Hat-based:
sudo yum install libsecret-devel- Arch Linux:
sudo pacman -S libsecret
CLI Flag
passing --no-store in the CLI of parent app, will automatically skip using the keychain
API
Method : _(namespace)
creates a new namespace in the system's keychain, returns an Object with two methods: token & reset
| name | type | required | default | description |
|---|---|---|---|---|
namespace | String | ✓ | - | namespace value to use in keychain |
const auth = require('@ahmadnassri/github-cli-auth')
const { token, reset } = auth('my-awesome-app')Method : token([options])
creates a personal access token for supplied scopes, prompts for username, password & 2FA as needed.
Options
| name | type | required | default | description |
|---|---|---|---|---|
remember | Object | ✗ | { lastuser: true, password: false } | store additional info |
scopes | Array | ✗ | ['repo'] | scopes to authenticate |
const auth = require('@ahmadnassri/github-cli-auth')
const { token } = auth('my-awesome-app')
token({ scopes: ['admin:org', 'repo'] }).then(console.log)
//=> { username: 'ahmadnassri', token: '88688d7a17c52e893e6dc27a2d22734955740c04' }Method : reset(username)
delete stored secrets for a given username
| name | type | required | default | description |
|---|---|---|---|---|
username | String | ✓ | - | username to erase |
const auth = require('@ahmadnassri/github-cli-auth')
const { reset } = auth('my-awesome-app')
reset('ahmadnassri') // deletes stored secrets for 'ahmadnassri'Debug
Set NODE_DEBUG=GITHUB_AUTH for additional debug logs
Author: Ahmad Nassri • Github: @ahmadnassri • Twitter: @AhmadNassri