├── .gitignore ├── LICENSE ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Tobias Baunbæk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # github-with-auth 2 | 3 | Get started on creating CLI github programs in no time. 4 | 5 | Combines github + ghauth to make it faster to get started on using the github api. 6 | 7 | See https://github.com/mikedeboer/node-github for the instantiated object. 8 | 9 | ``` 10 | npm install github-with-auth 11 | ``` 12 | 13 | ## Usage 14 | 15 | ``` js 16 | var github = require('github-with-auth'); 17 | 18 | github(['repo'], function(err, github) { 19 | if (err) throw err; 20 | 21 | github.repos.get({user:'freeall', repo:'github-with-auth'}, function(err, repo) { 22 | console.log(repo); 23 | }); 24 | }); 25 | ``` 26 | 27 | ## License 28 | 29 | MIT -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var GH = require('github'); 2 | var ghauth = require('ghauth'); 3 | var path = require('path'); 4 | 5 | var pkg = {}; 6 | try { pkg = require(path.resolve('package.json')); } 7 | catch(err) {} 8 | 9 | var github = new GH({ 10 | version: '3.0.0', 11 | headers: { 12 | 'User-Agent': pkg.name || 'github-with-auth' 13 | } 14 | }); 15 | 16 | module.exports = function(scopes, callback) { 17 | ghauth({ 18 | configName: pkg.name || 'github-with-auth', 19 | scopes: scopes 20 | }, function(err, auth) { 21 | if (err) return callback(err); 22 | 23 | github.authenticate({ 24 | type: 'oauth', 25 | token: auth.token 26 | }); 27 | 28 | process.nextTick(function() { 29 | callback(null, github); 30 | }); 31 | }); 32 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "github-with-auth", 3 | "version": "1.0.1", 4 | "description": "Get started using the github in no time! Instantiates github module by using ghauth.", 5 | "dependencies": { 6 | "ghauth": "^2.0.0", 7 | "github": "^0.2.3" 8 | }, 9 | "devDependencies": {}, 10 | "author": "Tobias Baunbæk ", 11 | "license": "MIT", 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/freeall/github-with-auth.git" 15 | } 16 | } 17 | --------------------------------------------------------------------------------