npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

github-oauth-prompt

v1.1.0

Published

Easy creation of GitHub OAuth tokens for your app name

Downloads

6

Readme

github-oauth-prompt Build Status Coverage Status

![Gitter](https://badges.gitter.im/Join Chat.svg)

Easy creation of GitHub OAuth tokens.

Two-factor authentication is fully supported.

Getting Started

Install the module with: npm install github-oauth-prompt

var oauth = require('github-oauth-prompt');
oauth({name: 'my-token'}, function (err, token) {
    // Now you have a token.
});

Documentation

(Coming soon)

See Examples

Examples

In all examples below, callback is a function accepting two parameters: error and response.

function callback (err, res) {
    console.log('Token: ' + res);
}

Example 1

// Prompt for username, password, two-factor auth code if required,
// and return to the callback a GitHub token with basic scope.
oauth({
    name: 'moonrise-kingdom'
}, callback);

moonrise-kingdom demo gif

Example 2

// Prompt for a token for read/write access to all repositories
// and organisations and write access to Gists.
// More scopes: https://developer.github.com/v3/oauth/#scopes
oauth({
    name: 'rushmore',
    scopes: ['repo', 'gist']
}, callback);

rushmore demo gif

See that the token exists.

rushmore token in list

When called again, the existing token is returned.

rushmore demo existing gif

Example 3

// Set prompt messages.
oauth({
    name: 'the-life-aquatic',
    prompt: {
        username: 'Enter username:',
        password: 'Enter password:',
        code: 'Enter two-factor authorisation code'
    }
}, callback);

the-life-aquatic demo gif

Example 4

// Use own prompt. Must deal with two-factor authentication.
// Ask for username and password and store in an object. For this example, and
// to avoid getting bogged down in callback-hell, we have them already available.
var auth = {
    username: 'Margot',
    password: 'RichieLovesMe'
};
// Setup a function to call oauth with a code.
function getToken (code) {
    // Get a token with a two-factor authentication code.
    var authOptions = {
        name: 'the-royal-tenenbaums'
        username: auth.username,
        password: auth.password,
    };
    if (code) {
        authOptions.code = code;
    }
    oauth(authOptions, function (err, token) {
        console.log(token);
    });
}
// Test to see if a code is required for a given username and password.
oauth.requiresCode(auth, function (err, hasTwoFactorAuth) {
    if (!hasTwoFactorAuth) {
        // No need for a code.
        getToken();
    } else {
        // You need to get a two-factor authentication code from
        // the user.
        myCodePrompt(function (err, code) {
            getToken(code);
        });
    }
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

# Requirements
npm install -g grunt-cli
# Dev
npm install && grunt

Release History

  • v1.0.1 The Royal Tenenbaums: "Anybody interested in grabbing a couple of burgers and hittin' the cemetery?"
  • v1.0.0 The Royal Tenenbaums
  • v0.2.2 Rushmore: "What's the secret, Max?"
  • v0.2.1 Rushmore: "I saved Latin. What did you ever do?"
  • v0.2.0 Rushmore
  • v0.1.3 Bottle Rocket: "So, did you enjoy your first visit to the nut house?
  • v0.1.2 Bottle Rocket: "Tell Anthony I love him."
  • v0.1.1 Bottle Rocket: "Which part of Mexico are you from?"
  • v0.1.0 Bottle Rocket

License

Copyright (c) 2014 Henry Blyth. Licensed under the MIT license.