Example #1
0
                }, function(error, access_token, refresh_token) {
                    if (error)
                        return callback(error);

                    request.session.access_token = access_token;
                    if (refresh_token)
                        request.session.refresh_token = refresh_token;

                    var github = new Github({
                        version: "3.0.0"
                    });
                    github.authenticate({
                        type: "oauth",
                        token: access_token
                    });
                    github.user.get({}, function(err, data) {
                        if (err)
                            return self.fail(callback);
                        self.success(data, callback);
                    });
                });
Example #2
0
	signin : function(auth, callback, fromSignin) {
		if(this.session) return callback && callback(false);
		var authStorage = new Storage('github', window),
			githubClient = new github({
				version : '3.0.0'
			}),
			self = this;

		if(auth) authStorage.set('auth', auth);
		else auth = authStorage.get('auth');
		if(!auth || auth.username === '' || auth.password === '') {
			!fromSignin && this.load({
				repository : {
					type : 'git',
					url : config.signinRepo
				}
			}, {}, function(frapp) {
				frapp.FRAPP.window.title = frapp.WIN.title = L.signInWithGithub;
			});
			callback && callback(false);
			return;
		}
		githubClient.authenticate({
		    type : 'basic',
		    username : auth.username,
		    password : auth.password
		});
		githubClient.user.get({}, function(err, user) {
			if(err) return callback && callback(false);
			self.session = {
				API : githubClient,
				user : user
			};
			frapps.forEach(function(f) {
				lib.emitEvent(f, 'frapp.signin', {session : user});
			});
			callback && callback(self.session);
		});
	},
var path = require('path');
var GithubClient = require('node-github');

var github = new GithubClient({
    // required
    version: "3.0.0"
});

var EXCLUDED_COMPONENTS = [];
if (process.env.EXCLUDED_COMPONENTS) {
  EXCLUDED_COMPONENTS = process.env.EXCLUDED_COMPONENTS.split(",");
}

if (process.env.GITHUB_TOKEN){
  github.authenticate({
    type: "oauth",
    token: process.env.GITHUB_TOKEN
  });
}

function isComponentExcluded(repoOrFolderName) {
  return EXCLUDED_COMPONENTS.indexOf(repoOrFolderName) > -1;
}

function getUrlFromName(name){
  return '/component/mozilla-appmaker/' + name + '/component.html';
}

function unique(array){
  var a = array.concat();
  for (var i=0; i<a.length; ++i) {
    for (var j=i+1; j<a.length; ++j) {
Example #4
0
var GitHubApi = require("node-github");

var github = new GitHubApi({
    // required
    version: "3.0.0",
    // optional
    timeout: 5000
});

var token;

github.authenticate({
    type: "oauth",
    token: token
});

// Can get token with
// https://github.com/login/oauth/authorize?client_id=d955547d16b4c81efcb0&scope=repo

github.user.getFollowingFromUser({
    user: "******"
}, function(err, res) {
    console.log(JSON.stringify(res));
});
Example #5
0
 * I will probably refactor later.
 */
var github = new GitHubApi({
    version: '3.0.0',
    debug: true,
    protocol: 'https',
    host: 'api.github.com',
    pathPrefix: '/api/v3',
    timeout: 5000,
    headers: {
        'user-agent': 'My-Cool-GitHub-App'
    }
});

github.authenticate({
    type: 'oauth',
    token: process.env.NODE_GITHUB_TOKEN,
});

var repository = 'studyGroup';
var username = '******';

var offset = 0;
var pageSize = 33;

/* --- Google API initiation --- */
var sheets = google.sheets('v4');
var SHEET_ID = process.env.SHEET_ID;
var SHEET_NAME = process.env.SHEET_NAME;

// If modifying these scopes, delete your previously saved credentials
// at ./credentials/sheets.googleapis.com-nodejs-quickstart.json
 function createGitHub() {
     var github = new GitHubApi(gitHubOpts);
     github.authenticate(gitHubAuth);
     return github;
 }
Example #7
0
(function () {
    'use strict';

    var GitHubApi = require("node-github");
    var request = require('request');
    var deferred = require('deferred');

    var github = new GitHubApi({
        // required
        version: "3.0.0",
        // optional
        timeout: 5000
    });

    // OAuth2
    github.authenticate({
        type: "oauth",
        token: "YOUR TOKEN HERE"
    });

    var fetchRepos = function(opts) {
        var d = deferred();

        github.repos.getFromOrg({
            org: opts.org,
            page: opts.page,
            per_page: 100
        }, function(err, repos) {
            d.resolve(repos);
        });

        return d.promise();
    };

    var fetchRepoContributors = function(repo) {
        var d = deferred();

        github.repos.getContributors({
            user: orgName,
            repo: repo.name,
            anon: true
        }, function(err, data) {
            d.resolve({
                repo: repo,
                contributors: data
            });
        });

        return d.promise();
    };

    var orgName = 'goodData';

    var contributors = [];
    var repos = [];
    fetchRepos({
        org: orgName,
        page: 1
    }).then(function(data) {
        repos = repos.concat(data);
    }).then(fetchRepos({
        org: orgName,
        page: 2
    })).then(function(data) {
        repos = repos.concat(data);
    }).then(function() {
        var d = deferred();

        deferred.map(repos, function (repo) {
            // console.log(repo);
            return fetchRepoContributors(repo);
        })(function (result) {
            // result is an array of file's contents
            d.resolve(result);
        });

        return d.promise();
    }).then(function(data){
        contributors = data;
    }).done(function(res) {
        console.log('Repos Count: ' + repos.length);
        console.log(JSON.stringify(contributors, null, 2));
        // console.log('Done!');
    }, function(err) {
        console.log('Error: ' + err);
    });

}());