Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //from ./lib/google.js
- var googleapis = require('googleapis');
- var OAuth2 = googleapis.auth.OAuth2;
- var client = new OAuth2('clientId', 'clientSecret', '/oauth2callback');
- var plus = googleapis.plus('v1');
- exports.client = client;
- exports.plus = plus;
- //from app.js
- var gapi = require('./lib/google');
- app.get('/oauth2callback', function (req, res){
- var code = req.query.code;
- gapi.client.getToken(code, function (err, tokens) {
- gapi.client.setCredentials(tokens);
- gapi.plus.people.get({userId: 'me', auth: gapi.client}, function (err, resp){
- //use the resp object to get user data we want...
- });
- });
- });
Add Comment
Please, Sign In to add comment