All Projects → kgryte → Github Create Token

kgryte / Github Create Token

Licence: mit
Create a Github OAuth access token.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Github Create Token

Express Graphql Mongodb Boilerplate
A boilerplate for Node.js apps / GraphQL-API / Authentication from scratch - express, graphql - (graphql compose), mongodb (mongoose).
Stars: ✭ 288 (+4700%)
Mutual labels:  api, authentication, authorization, token
Express Mongodb Rest Api Boilerplate
A boilerplate for Node.js apps / Rest API / Authentication from scratch - express, mongodb (mongoose).
Stars: ✭ 153 (+2450%)
Mutual labels:  api, authentication, authorization, token
Jso
Easy to use OAuth 2.0 javascript library for use in your javascript application.
Stars: ✭ 830 (+13733.33%)
Mutual labels:  api, authentication, authorization
Appy Backend
A user system to bootstrap your app.
Stars: ✭ 96 (+1500%)
Mutual labels:  api, authentication, authorization
Hwioauthbundle
OAuth client integration for Symfony. Supports both OAuth1.0a and OAuth2.
Stars: ✭ 2,150 (+35733.33%)
Mutual labels:  api, authentication, oauth
Pizzly
The simplest, fastest way to integrate your app with an OAuth API 😋
Stars: ✭ 796 (+13166.67%)
Mutual labels:  api, authentication, oauth
Awesome Iam
👤 Identity and Access Management Knowledge for Cloud Platforms
Stars: ✭ 186 (+3000%)
Mutual labels:  authentication, authorization, oauth
Security.identity
.NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities
Stars: ✭ 165 (+2650%)
Mutual labels:  authentication, authorization, oauth
Devise token auth
Token based authentication for Rails JSON APIs. Designed to work with jToker and ng-token-auth.
Stars: ✭ 3,263 (+54283.33%)
Mutual labels:  api, authentication, oauth
Annon.api
Configurable API gateway that acts as a reverse proxy with a plugin system.
Stars: ✭ 306 (+5000%)
Mutual labels:  api, authentication, authorization
Grant
OAuth Proxy
Stars: ✭ 3,509 (+58383.33%)
Mutual labels:  authentication, authorization, oauth
Doorkeeper
Doorkeeper is an OAuth 2 provider for Ruby on Rails / Grape.
Stars: ✭ 4,917 (+81850%)
Mutual labels:  authentication, authorization, oauth
Oauthlib
A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
Stars: ✭ 2,323 (+38616.67%)
Mutual labels:  authentication, authorization, oauth
Spring Security Pac4j
pac4j security library for Spring Security: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 231 (+3750%)
Mutual labels:  authentication, authorization, oauth
Pac4j
Security engine for Java (authentication, authorization, multi frameworks): OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 2,097 (+34850%)
Mutual labels:  authentication, authorization, oauth
Play Pac4j
Security library for Play framework 2 in Java and Scala: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 375 (+6150%)
Mutual labels:  authentication, authorization, oauth
Fosite
Extensible security first OAuth 2.0 and OpenID Connect SDK for Go.
Stars: ✭ 1,738 (+28866.67%)
Mutual labels:  authentication, authorization, oauth
Spark Pac4j
Security library for Sparkjava: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 154 (+2466.67%)
Mutual labels:  authentication, authorization, oauth
Securing Restful Apis With Jwt
How to secure a Nodejs RESTful CRUD API using JSON web tokens?
Stars: ✭ 301 (+4916.67%)
Mutual labels:  api, authentication, authorization
Angular Token
🔑 Token based authentication service for Angular with interceptor and multi-user support. Works best with devise token auth for Rails. Example:
Stars: ✭ 376 (+6166.67%)
Mutual labels:  authentication, oauth, token

Create Token

NPM version Build Status Coverage Status Dependencies

Create a Github OAuth access token.

Installation

$ npm install github-create-token

Usage

var createToken = require( 'github-create-token' );

createToken( options, clbk )

Creates a Github OAuth access token.

var opts = {
	'username': 'beep',
	'password': 'boop',
	'scopes': [ 'public_repo', 'read:org' ],
	'note': 'beep'
};

createToken( opts, clbk );

function clbk( error, results, info ) {
	// Check for rate limit information...
	if ( info ) {
		console.error( 'Limit: %d', info.limit );
		console.error( 'Remaining: %d', info.remaining );
		console.error( 'Reset: %s', (new Date( info.reset*1000 )).toISOString() );
	}
	if ( error ) {
		throw new Error( error.message );
	}
	console.log( JSON.stringify( results ) );
	/* returns
		{
			"id": 1,
			"url":"https://api.github.com/authorizations/1",
			"app": {
				"name":"beep",
				"url":"https://developer.github.com/v3/oauth_authorizations/",
				"client_id":"00000000000000000000"
			},
			"token": "abcdefgh12345678",
			"hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
			"token_last_eight": "12345678",
			"note": "beep",
			"note_url": null,
			"created_at": "2016-03-05T06:34:01Z",
			"updated_at": "2016-03-05T06:34:01Z",
			"scopes": [
				"public_repo",
				"read:org"
			],
			"fingerprint": null
		}
	*/
}

The function accepts the following options:

  • username: Github username (required).
  • password: Github password (required).
  • scopes: list of scopes (required).
  • note: a note as to the purpose of the token (required).
  • otp: Github one-time password (2-factor authentication).
  • note_url: an app URL if authorizing an application.
  • client_id: a 20 character OAuth app client key for which to create the token.
  • client_secret: a 40 character OAuth app client secret for which to create the token.
  • fingerprint: a unique string to distinguish a token from others created for the same client id and user.
  • useragent: user agent string.

The function only supports basic authentication using a username and password. To authenticate with Github, set the username and password options.

var opts = {
	'username': 'beep',
	'password': 'boop',
	'scopes': [ 'public_repo' ],
	'note': 'for my beepboop app'
};

createToken( opts, clbk );

To specify a user agent, set the useragent option.

var opts = {
	'username': 'beep',
	'password': 'boop',
	'scopes': [ 'public_repo' ],
	'note': 'for my beepboop app',
	'useragent': 'hello-github!'
};

createToken( opts, clbk );

If a user has two-factor authentication enabled, set the otp (one-time password) option.

var opts = {
	'username': 'beep',
	'password': 'boop',
	'otp': '1234',
	'scopes': [ 'public_repo' ],
	'note': 'for my beepboop app'
};

createToken( opts, clbk );

Notes

  • Rate limit information includes the following:
    • limit: maximum number of requests a consumer is permitted to make per hour.
    • remaining: number of remaining requests.
    • reset: time at which the current rate limit window resets in UTC seconds.

Examples

var createToken = require( 'github-create-token' );

var opts = {
	'username': '<username>',
	'password': '<password>',
	'otp': '<otp>',
	'scopes': [ 'public_repo' ],
	'note': 'for my beepboop app',
	'useragent': 'beep-boop-bop'
};

createToken( opts, clbk );

function clbk( error, results, info ) {
	if ( info ) {
		console.error( info );
	}
	if ( error ) {
		throw new Error( error.message );
	}
	console.log( results );
}

To run the example code from the top-level application directory,

$ node ./examples/index.js

CLI

Installation

To use the module as a general utility, install the module globally

$ npm install -g github-create-token

Usage

Usage: ghcreatetoken [options]

Options:

  -h,  --help                      Print this message.
  -V,  --version                   Print the package version.
       --lscopes                   List all possible scopes.
       --username username         Github username.
       --password password         Github password.
       --otp password              Github one-time password.
  -ua, --useragent ua              User agent.
       --scopes scope1,scope2,...  List of scopes.
       --note note                 Token note.
       --note_url url              Application URL.
       --client_id id              Client id.
       --client_secret secret      Client secret.
       --fingerprint fingerprint   Unique token identifier.

Notes

  • If a username is not provided, the implementation will attempt to infer a username by executing

    git config user.name
    

    in the current working directory.

  • If a password is not provided, the user will be prompted to provide a password.

  • In addition to the username and password options, a username and password may also be specified by GITHUB_USERNAME and GITHUB_PASSWORD environment variables. The command-line options always take precedence.

  • Token information is written to stdout.

  • Rate limit information is written to stderr.

Examples

Setting a username and password using the command-line options:

$ DEBUG=* ghcreatetoken --username <username> --password <password> --scopes=read_org,repo_status --note 'for my beepboop app'
# => '{...}'

Setting a username and password using environment variables:

$ DEBUG=* GITHUB_USERNAME=<username> GITHUB_PASSWORD=<password> ghcreatetoken --scopes=read_org,repo_status --note 'for my beepboop app'
# => '{...}'

For local installations, modify the command to point to the local installation directory; e.g.,

$ DEBUG=* ./node_modules/.bin/ghcreatetoken --scopes=read_org,repo_status --note 'for my beepboop app'
# => '{...}'

Or, if you have cloned this repository and run npm install, modify the command to point to the executable; e.g.,

$ DEBUG=* node ./bin/cli --scopes=read_org,repo_status --note 'for my beepboop app'
# => '{...}'

Tests

Unit

This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

Browser Support

This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:

$ make test-browsers

To view the tests in a local web browser,

$ make view-browser-tests

License

MIT license.

Copyright

Copyright © 2016. Athan Reines.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].