deauth(refreshToken) {

    // no need to deauth if not authenticated
    if (!this.hasAccessToken()) {
      return when.resolve();
    }

    let isRefreshToken = typeof refreshToken === 'string';

    let token = isRefreshToken ? refreshToken : this.accessToken;

    let tokenTypeHint = isRefreshToken ? 'refresh_token' : 'access_token';

    let params = {
      token: token,
      token_type_hint: tokenTypeHint
    };

    let auth = 'Basic ' + (new Buffer(
      this._userConfig.oauth.key + ':' +
      this._userConfig.oauth.secret)).toString('base64');

    let headers = {
      'Authorization': auth
    };

    let endpoint = new Endpoint(this._userConfig,
                                this._userConfig.serverWWW,
                                'post',
                                '/api/v1/revoke_token',
                                headers,
                                params,
                                {},
                                this._userConfig.serverWWWPort);

    return this._request.https(endpoint).then(response => {
      // If we did not get back a 204 this then it did not sucessfully
      // revoke the token
      if (response._status !== 204) {
        return when.reject(new Error('Unable to revoke the given token'));
      }

      // clear the data for this OAuth object
      this.accessToken = TOKEN.INVALID;
      this.tokenType = TOKEN.INVALID;

      // only clear the refresh token if one was provided
      if (isRefreshToken) {
        this.refreshToken = TOKEN.INVALID;
      }
    });
  }
/*
     Clears any authentication data & removes OAuth authentication

     By default it will only remove the "access_token". Specify
     the users refresh token to revoke that token instead.
   */
Clears any authentication data & removes OAuth authentication
By default it will only remove the "access_token". Specify
the users refresh token to revoke that token instead.
Clears any authentication data & removes OAuth authentication By default it will only remove the " access_token " . Specify the users refresh token to revoke that token instead .
deauth(refreshToken) {
    if (!this.hasAccessToken()) {
      return when.resolve();
    }
    let isRefreshToken = typeof refreshToken === 'string';
    let token = isRefreshToken ? refreshToken : this.accessToken;
    let tokenTypeHint = isRefreshToken ? 'refresh_token' : 'access_token';
    let params = {
      token: token,
      token_type_hint: tokenTypeHint
    };
    let auth = 'Basic ' + (new Buffer(
      this._userConfig.oauth.key + ':' +
      this._userConfig.oauth.secret)).toString('base64');
    let headers = {
      'Authorization': auth
    };
    let endpoint = new Endpoint(this._userConfig,
                                this._userConfig.serverWWW,
                                'post',
                                '/api/v1/revoke_token',
                                headers,
                                params,
                                {},
                                this._userConfig.serverWWWPort);
    return this._request.https(endpoint).then(response => {
      if (response._status !== 204) {
        return when.reject(new Error('Unable to revoke the given token'));
      }
      this.accessToken = TOKEN.INVALID;
      this.tokenType = TOKEN.INVALID;
      if (isRefreshToken) {
        this.refreshToken = TOKEN.INVALID;
      }
    });
  }
deauth ( refreshToken ) { if ( ! this . hasAccessToken ( ) ) { return when . resolve ( ) ; } let isRefreshToken = typeof refreshToken === 'string' ; let token = isRefreshToken ? refreshToken : this . accessToken ; let tokenTypeHint = isRefreshToken ? 'refresh_token' : 'access_token' ; let params = { token : token , token_type_hint : tokenTypeHint } ; let auth = 'Basic ' + ( new Buffer ( this . _userConfig . oauth . key + ':' + this . _userConfig . oauth . secret ) ) . toString ( 'base64' ) ; let headers = { 'Authorization' : auth } ; let endpoint = new Endpoint ( this . _userConfig , this . _userConfig . serverWWW , 'post' , '/api/v1/revoke_token' , headers , params , { } , this . _userConfig . serverWWWPort ) ; return this . _request . https ( endpoint ) . then ( response => { if ( response . _status !== 204 ) { return when . reject ( new Error ( 'Unable to revoke the given token' ) ) ; } this . accessToken = TOKEN . INVALID ; this . tokenType = TOKEN . INVALID ; if ( isRefreshToken ) { this . refreshToken = TOKEN . INVALID ; } } ) ; }
Clears any authentication data & removes OAuth authentication
By default it will only remove the "access_token".
Clears any authentication data & removes OAuth authentication By default it will only remove the " access_token " .
// no need to deauth if not authenticated // If we did not get back a 204 this then it did not sucessfully // revoke the token // clear the data for this OAuth object // only clear the refresh token if one was provided