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 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-github-oauth2

v0.1.21

Published

This repository contains node module for authenticating with github and interacting with github.

Readme

Node Github oauth2

This repository contains node module for authenticating with github and interacting with github.

Demo:

/**
 * Created by amitthakkar on 14/07/16.
 */
var express = require('express'),
    app = express();

const NodeGithubOAuth2 = require('node-github-oauth2');
NodeGithubOAuth2.initialize({
    clientId: 'ZZZZZZZZZZZZZZZZZZZZ',
    clientSecret: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    redirectURI: 'http://localhost:3000/callback',
    scope: 'repo,admin:org,delete_repo',
    userAgent: 'Github-Test-App',
    gitDirectory: '/Users/amitthakkar/My Stuff/Projects/OSP/'
});

// Initial page redirecting to Github
exports.authorized = (request, response) => {
    response.status(200).json({redirectURL: NodeGithubOAuth2.getRedirectURL(request.user._id.toString())});
};

// Callback service parsing the authorization token and asking for the access token
app.get('/callback', NodeGithubOAuth2.getToken, function (request, response) {
    console.log(request.token)
    response.json(request.token);
}, function (error, request, res, next) {
    console.log('Access Token Error', error.message);
    res.json(error);
});


exports.authorizedCallback = [NodeGithubOAuth2.getToken, (request, response) => {
    let token = request.token;
    let _id = request.state;
    NodeGithubOAuth2.getUserDetails({
        token: token
    }, (error, user) => {
        if (!user.email) {
            NodeGithubOAuth2.getEmailIds({
                token: token
            }, (error, emailIds) => {
                let emailId = emailIds.filter((email) => {
                    return email.primary;
                })[0];
                // User Details
                console.log({
                    token: token,
                    username: user.login,
                    email: emailId.email
                });
            });
        } else {
            console.log({
                token: token,
                username: user.login,
                email: emailId.email
            });
        }
    });
}];

app.get('/', function (req, res) {
    res.send('Hello<br><a href="/auth">Log in with Github</a>');
});

app.get('/orgs', function (req, res) {
    NodeGithubOAuth2.getOrganization({
        token: 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
    }, function (error, result) {
        res.json(result);
    });
});

app.get('/createProject', function (req, res) {
    NodeGithubOAuth2.createRepoAndCloneProject({
        token: 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY',
        org: 'OrganizationName',
        name: 'ngt1',
        description: 'Node-Git-Test-2',
        private: true
    }, function (error, result) {
        res.json(result);
    });
});

app.get('/cloneProject', function (req, res) {
    NodeGithubOAuth2.cloneProject({
        token: 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY',
        org: 'OrganizationName',
        name: 'ngt1',
        description: 'Node-Git-Test-2',
        private: true
    }, function (error, result) {
        res.json(result);
    });
});

app.get('/deleteProject', function (req, res) {
    NodeGithubOAuth2.deleteGithubRepo({
        token: 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY',
        org: 'OrganizationName',
        name: 'ngt1'
    }, function (error, result) {
        res.json(result);
    });
});

app.get('/addCollaborators', function (req, res) {
    NodeGithubOAuth2.addCollaborators({
        token: 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY',
        user: 'OrganizationName',
        repo: 'ngt1',
        collabuser: 'NamitaMalik',
        permission: 'admin'
    }, function (error, result) {
        if (error) {
            res.json(result);
        } else {
            res.json(result);
        }
    });
});

app.get('/removeCollaborator', function (req, res) {
    NodeGithubOAuth2.removeCollaborator({
        token: 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY',
        user: 'OrganizationName',
        repo: 'ngt1',
        collabuser: 'NamitaMalik'
    }, function (error, result) {
        if (error) {
            res.json(result);
        } else {
            res.json(result);
        }
    });
});

app.get('/commitAndPush', function (req, res) => {
    NodeGithubOAuth2.commitAndPush({
        token: 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY',
        email: '[email protected]',
        name: 'projectName',
        username: 'AmitThakkar',
        org: 'NA',
        commitMessage: 'Commit by Wize Server'
    }, (error, result) => {
        NodeGithubOAuth2.createRelease({
            token: options.github.token,
            user: options.org,
            repo: options.name,
            tag_name: options.tag
        }, function (error, result) {
            res.json(result);
        });
    });
});

exports.updateProject = (req, res) => {
    NodeGithubOAuth2.updateProject({
        token: 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY',
        name: 'projectName',
        username: 'AmitThakkar',
        org: 'NA'
    }, function (error, result) {
        res.json(result);
    });
};

app.listen(3000);

console.log('Express server started on port 3000');