src/es5-gfycat-sdk.js
function(options, callback) {
    if (!options) options = {};
    if (!(this.client_id || this.client_secret) && !(options.client_id || options.client_secret)) {
      return _handleErr('Please provide client_id and client_secret in options', callback);
    }

    var options = {
      api: '/oauth',
      endpoint: '/token',
      method: 'POST',
      payload: {
        client_id: options.client_id || this.client_id,
        client_secret: options.client_secret || this.client_secret,
        grant_type: options.grant_type || 'client_credentials'
      }
    }

    var self = this;

    if (callback) {
      return this._request(options, function(err, res) {
        if (!err) {
          self._setToken(res);
          callback(null, res);
        } else callback(err);
      })
    } else {
      return this._request(options)
        .then(function(res) {
          self._setToken(res);
          Promise.resolve(res);
        })
        .catch(function(err) {
          Promise.reject(err);
        })
    }
  }
function(options, callback) {
    if (!options) options = {};
    if (!(this.client_id || this.client_secret) && !(options.client_id || options.client_secret)) {
      return _handleErr('Please provide client_id and client_secret in options', callback);
    }

    var options = {
      api: '/oauth',
      endpoint: '/token',
      method: 'POST',
      payload: {
        client_id: options.client_id || this.client_id,
        client_secret: options.client_secret || this.client_secret,
        grant_type: options.grant_type || 'client_credentials'
      }
    }

    var self = this;

    if (callback) {
      return this._request(options, function(err, res) {
        if (!err) {
          self._setToken(res);
          callback(null, res);
        } else callback(err);
      })
    } else {
      return this._request(options)
        .then(function(res) {
          self._setToken(res);
          Promise.resolve(res);
        })
        .catch(function(err) {
          Promise.reject(err);
        })
    }
  }
function ( options , callback ) { if ( ! options ) options = { } ; if ( ! ( this . client_id || this . client_secret ) && ! ( options . client_id || options . client_secret ) ) { return _handleErr ( 'Please provide client_id and client_secret in options' , callback ) ; } var options = { api : '/oauth' , endpoint : '/token' , method : 'POST' , payload : { client_id : options . client_id || this . client_id , client_secret : options . client_secret || this . client_secret , grant_type : options . grant_type || 'client_credentials' } } var self = this ; if ( callback ) { return this . _request ( options , function ( err , res ) { if ( ! err ) { self . _setToken ( res ) ; callback ( null , res ) ; } else callback ( err ) ; } ) } else { return this . _request ( options ) . then ( function ( res ) { self . _setToken ( res ) ; Promise . resolve ( res ) ; } ) . catch ( function ( err ) { Promise . reject ( err ) ; } ) } }
Retrieve Oauth token.

@param options - (optional if id and secret were provided in constructor)
@param {string} options.client_id - Gfycat client id.
@param {string} options.client_secret - Gfycat client secret.
@param {string} options.grant_type - Oauth grant type. 'client_credentials' by default.
@param {requestCallback} callback - (optional) callback function to run when the request completes.
Retrieve Oauth token .