GoogleAPIsOAuth2v2.getAccessToken()

Getting access token using authorization token that Google provided you with

Usage

Hover over inputs/exits for more info.

var GoogleAPIsOAuth2v2 = require('machinepack-googleapisoauth2v2');


// Getting access token using authorization token that Google provided you with

GoogleAPIsOAuth2v2.getAccessToken({

clientId: '284875887706-4gku5u85022s3cbsde5rpvps88ekcfql.apps.googleusercontent.com',

clientSecret: 'SomeSuperSecretKey',

redirectUrl: 'http://localhost:1337/user/google/login',

code: 'someSuperCodeYouGotFromGoogle',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Triggers if some of input variables are wrong.

invalidRequest: function () {

 

},

// Triggers if code is wrong.

invalidToken: function () {

 

},

// OK.

success: function () {

 

},

});

Inputs

clientId required

OAuth2 Client ID

'284875887706-4gku5u85022s3cbsde5rpvps88ekcfql.apps.googleusercontent.com'
clientSecret required

OAuth2 Client Secret key

'SomeSuperSecretKey'
redirectUrl required

The callback URL where the end user will be redirected after visiting the login URL returned by this machine

'http://localhost:1337/user/google/login'
code required

With the code returned, you can ask for an access token

'someSuperCodeYouGotFromGoogle'

Exits

error

An unexpected error occurred.

invalidRequest

Triggers if some of input variables are wrong.

invalidToken

Triggers if code is wrong.

success

OK.