This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
getAccessToken
Alex Vernacchia edited this page Mar 10, 2015
·
2 revisions
-
getAccessToken( options, callback )
-
options
- required: no
- Type:
Object
- Extra options used on token request. See [request modules options][3]
-
options.force
- required: no
- Type:
Boolean
- default:
false
- If true, token will always be requested from API regardless of expiration
-
callback( error, data )
- required: yes
- Type:
Function
- Function that will be executed after token request completes
-
parameters
- error - error encountered.
null
if no error - data - object with data and response
- accessToken ( data.accessToken ) - access token
- expiresIn ( data.expiresIn ) - time until token expiration
- error - error encountered.
-
var options = {
// whatever request options you want
// See https://github.com/mikeal/request#requestoptions-callback
// I want to force a request
force: true
};
FuelAuthClient.getAccessToken( options, function( err, data ) {
if( !!err ) {
console.log( err );
return;
}
// data.accessToken = your token
// data.expiresIn = how long until token expiration
console.log( data );
});
// OR don't pass any options
FuelAuthClient.getAccessToken( function( err, data ) {
if( !!err ) {
console.log( err );
return;
}
// data.accessToken = your token
// data.expiresIn = how long until token expiration
console.log( data );
});