public function acquireToken(int $duration = null, bool $reset = false): Token
    {
        if ($reset) {
            $this->tokenCachePool->deleteToken($this);
        }

        // We assume that the cache is backed by shared storage across multiple
        // requests. In that case, it's possible for another thread to set a
        // token between the above delete and the next try block.
        try {
            $token = $this->tokenCachePool->getToken($this);
        } catch (TokenNotFoundException $e) {
            $token = $this->signInWithLock($duration);
        }

        return $token;
    }
public function acquireToken(int $duration = null, bool $reset = false): Token
    {
        if ($reset) {
            $this->tokenCachePool->deleteToken($this);
        }

        // We assume that the cache is backed by shared storage across multiple
        // requests. In that case, it's possible for another thread to set a
        // token between the above delete and the next try block.
        try {
            $token = $this->tokenCachePool->getToken($this);
        } catch (TokenNotFoundException $e) {
            $token = $this->signInWithLock($duration);
        }

        return $token;
    }
public function acquireToken ( int $ duration = null , bool $ reset = false ) : Token { if ( $ reset ) { $ this -> tokenCachePool -> deleteToken ( $ this ) ; } // We assume that the cache is backed by shared storage across multiple // requests. In that case, it's possible for another thread to set a // token between the above delete and the next try block. try { $ token = $ this -> tokenCachePool -> getToken ( $ this ) ; } catch ( TokenNotFoundException $ e ) { $ token = $ this -> signInWithLock ( $ duration ) ; } return $ token ; }
Get a current authentication token for the account.

This method will automatically generate a new token if one does not exist.

@todo Do we want to make this async?

@param int  $duration (optional) The number of seconds for which the token should be valid.
@param bool $reset    Force fetching a new token, even if one exists.

@return Token A valid mpx authentication token.
Get a current authentication token for the account .