Project

octoauth

0.0
Low commit activity in last 3 years
No release in over a year
Lightweight wrapper to sanely handle OAuth tokens with Octokit
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.7
~> 5.0.0
~> 3.7.6

Runtime

~> 5.6.1
~> 1.0.2
 Project Readme

octoauth

Gem Version GitHub Workflow Status MIT Licensed

Authentication wrapper for GitHub's API

Usage

Get your authentication token quickly and simply:

require 'octoauth'

auth = Octoauth.new note: 'my_cool_app'
puts "My token is #{auth.token}"

This will prompt the user for a username/password and potentially 2FA token using userinput. A note is required, and is what the token will appear as in the user's GitHub tokens list.

If you want to store this token and reuse it, just drop it into a file. The default file is ~/.octoauth.yml. Subsequent runs with the same file and note will load the same token without prompting the user:

auth = Octoauth.new note: 'my_cooler_app', file: :default
puts "My token is #{auth.token}"
auth.save

other_auth = Octoauth.new note: 'other_nice_app', file: '~/.other_app_config.yml'
puts "The other token is #{other_auth.token}"
other_auth.save

Multiple files can be specified, and it will try them in order looking for a valid token. If this fails, it will use the first file listed for any future saving of tokens:

auth = Octoauth.new note: 'my_app', files: ['./.octoauth.yml', '/etc/octoauth', :default]

The above examples get us the basic scope, which means some read-only public access. For other scopes, specify them when creating the token:

auth = Octoauth.new note: 'my_app', scopes: ['gist', 'delete_repo']

If you're trying to use this with a GitHub Enterprise deployment, you can specify an alternate API endpoint:

auth = Octoauth.new note: 'enterprise_app', api_endpoint: 'https://sekrit.codez.com/api/v3/'

If an alternate endpoint is provided, that string is included as part of the saved config, so you can generate a token for GitHub and multiple alternate endpoints with the same note in the same config file.

Installation

gem install octoauth

License

octoauth is released under the MIT License. See the bundled LICENSE file for details.