Facebook.getAccessToken()

Generate a new access token for acting on behalf of a particular Facebook user account.

Note that you must first have a valid `code` from the user proving that they're OK with this. You can get a code by redirecting the user to the url generated by calling the `getLoginUrl(...)` machine.

Usage

Hover over inputs/exits for more info.

var Facebook = require('machinepack-facebook');


// Generate a new access token for acting on behalf of a particular Facebook user account.

Facebook.getAccessToken({

appId: '215798311808508',

appSecret: 'dsg4901g0123456',

code: 'AQDvCav5zRSafS795TckAerUV53xzgqRyrcfYX2i_PJFObCvACVRP-V7sfemiMPBh3TWypvagfZ6aoqfwKCNcBxg8XR_skdYUe5tsY9UzX9Z_8q4mRrqaLhwSh5OHj9ORmE4ocyd-neZtdceTZjlmEVeO38UH9QOe_md7h5hy2gMhOS6TL9IBk5Guxg3O6I0WmjpFNPoj6JzWIvG9cgj7RQqxMA2q_8EJxGPTqEbmTqOBqqCIOlvPEPCeIiy21VD9__tuzB0JvgqbVh-U_WW8mjwGBqsfxlNvjYwIxk4zBNAxuRJijkkn0TwyogFpZqIlkY',

callbackUrl: 'http://localhost:1337/user/facebook/login',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

appId required

The unique identifier for your Facebook app (i.e. this is the "App ID" listed on your app's dashboard page in the Facebook developer portal, e.g. https://developers.facebook.com/apps/215293311518502/dashboard)

'215798311808508'
appSecret required

The developer "secret" for your Facebook app (i.e. this is the "App Secret" listed on your app's dashboard page in the Facebook developer portal)

'dsg4901g0123456'
code required

The OAuth `code` generated by Facebook and sent to the `callbackUrl` if the user chooses to grant your app the requested permissions

'AQDvCav5zRSafS795TckAerUV53xzgqRyrcfYX2i_PJFObCvACVRP-V7sfemiMPBh3TWypvagfZ6aoqfwKCNcBxg8XR_skdYUe5tsY9UzX9Z_8q4mRrqaLhwSh5OHj9ORmE4ocyd-neZtdceTZjlmEVeO38UH9QOe_md7h5hy2gMhOS6TL9IBk5Guxg3O6I0WmjpFNPoj6JzWIvG9cgj7RQqxMA2q_8EJxGPTqEbmTqOBqqCIOlvPEPCeIiy21VD9__tuzB0JvgqbVh-U_WW8mjwGBqsfxlNvjYwIxk4zBNAxuRJijkkn0TwyogFpZqIlkY'
callbackUrl required

The redirect URL that was used when generating the provided `code`

'http://localhost:1337/user/facebook/login'

Exits

error

An unexpected error occurred.

success

OK.

{ token: 'CA2Emk9XsJUIBAHB9sTF5rOdNmAXTDjiHxZaZC1GYtFZCcdYGVnLYZB7jZCvensIpGc22yEzN6CL6wtQ9LPVXTNkuP6eQoUQ0toEVPrmTTqDpj0POijBpsuZBnx7jrZCHaTw8leiZBn0R8u6gZAYZAuD77cA3tnDMYvHhrl42CnljROeC9maWoa5zbsT2TZBXdL9wEuGQDSxKqRPyajRw3P3HEK',
  expires: '2014-11-20T20:34:26.632Z' }