Thursday 16 February 2017

Get gitlab privateToken using passport-gitlab2

I am trying to create an issue board for my gitlab installation using node.js. I am able to use passport-gitlab2 to get user authentication which I want to use to pass a private token to access the gitlab api via node-gitlab but am unable to see where to get the token.The code I am using is below. Minus a info.js file which I use to store access keys.var passport = require("passport"); var gitlabAuth = require("passport-gitlab2"); var info = require("./info.js"); var express = require("express"); var morgan = require('morgan'); var gitlab = require('node-gitlab'); var opts = {}; opts.port = 3000; var app = express(); app.use(morgan('common')); var admin = express.Router(); app.use(require('serve-static')(__dirname + '/../../public')); app.use(require('express-session')({ secret: 'keyboard cat', resave: true, saveUninitialized: true })); app.use(passport.initialize()); app.use(passport.session()); console.log("Server running on port: " + opts.port); passport.use(new gitlabAuth({ clientID: info.gitlabID, clientSecret: info.gitlabSecret, callbackURL: "http://ift.tt/2lmQd9J", baseURL: "http://git.bertie.io" }, function(accessToken, refreshToken, profile, cb) { console.log(profile); } )); app.get('/', function(req, res) { res.send('Hello World') }) app.get('/auth/gitlab', passport.authenticate('gitlab', { failureRedirect: '/login' }) ); function gitLabTest(code) { var client = gitlab.create({ api: 'http://ift.tt/2lUYyP1', privateToken: info.pvTest }); client.issues.list({id: 1}, function (err, milestones) { console.log(err, milestones); }); } app.listen(3000)

Submitted February 16, 2017 at 10:59AM by SteamPunk_Devil

No comments:

Post a Comment