1.1.3 • Published 6 years ago

@ahmadnassri/github-cli-auth v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

GitHub Auth CLI Helper

License version Build Status

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-auth

OS Support

OSSecret ManagerSetup Needed
macOSKeychain
WindowsCredential Vault
LinuxSecret Service API Draft / libsecret

Linux Setup: Install libsecret before running npm 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

nametyperequireddefaultdescription
namespaceString-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

nametyperequireddefaultdescription
rememberObject{ lastuser: true, password: false }store additional info
scopesArray['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

nametyperequireddefaultdescription
usernameString-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

1.1.3

6 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago