public function getAccessToken()
    {
        // If token is not set try to get it from the persistent storage.
        if ($this->rawToken === null) {
            $this->rawToken = $this->tokenPersistence->restoreToken(new Token\RawToken());
        }

        // If token is not set or expired then try to acquire a new one...
        if ($this->rawToken === null || $this->rawToken->isExpired()) {
            $this->tokenPersistence->deleteToken();

            // Hydrate `rawToken` with a new access token
            $this->requestNewAccessToken();

            // ...and save it.
            if ($this->rawToken) {
                $this->tokenPersistence->saveToken($this->rawToken);
            }
        }

        return $this->rawToken? $this->rawToken->getAccessToken(): null;
    }
public function getAccessToken()
    {
        // If token is not set try to get it from the persistent storage.
        if ($this->rawToken === null) {
            $this->rawToken = $this->tokenPersistence->restoreToken(new Token\RawToken());
        }

        // If token is not set or expired then try to acquire a new one...
        if ($this->rawToken === null || $this->rawToken->isExpired()) {
            $this->tokenPersistence->deleteToken();

            // Hydrate `rawToken` with a new access token
            $this->requestNewAccessToken();

            // ...and save it.
            if ($this->rawToken) {
                $this->tokenPersistence->saveToken($this->rawToken);
            }
        }

        return $this->rawToken? $this->rawToken->getAccessToken(): null;
    }
public function getAccessToken ( ) { // If token is not set try to get it from the persistent storage. if ( $ this -> rawToken === null ) { $ this -> rawToken = $ this -> tokenPersistence -> restoreToken ( new Token \ RawToken ( ) ) ; } // If token is not set or expired then try to acquire a new one... if ( $ this -> rawToken === null || $ this -> rawToken -> isExpired ( ) ) { $ this -> tokenPersistence -> deleteToken ( ) ; // Hydrate `rawToken` with a new access token $ this -> requestNewAccessToken ( ) ; // ...and save it. if ( $ this -> rawToken ) { $ this -> tokenPersistence -> saveToken ( $ this -> rawToken ) ; } } return $ this -> rawToken ? $ this -> rawToken -> getAccessToken ( ) : null ; }
Get a valid access token.

@return string|null A valid access token or null if unable to get one

@throws AccessTokenRequestException while trying to run `requestNewAccessToken` method
Get a valid access token .