Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

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

Examples

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 );
});
Clone this wiki locally