examples/ExampleFabric.php
private function getToken($accessTokenParams)
    {
        $kvs = $this->getKeyValueStorage();

        if ($kvs->has(self::ACCESS_TOKEN_KEY) && $kvs->has(self::REFRESH_TOKEN_KEY)) {
            return new AccessToken([
                'access_token' => $kvs->get(self::ACCESS_TOKEN_KEY),
                'expires_in' => $kvs->getTtl(self::ACCESS_TOKEN_KEY),
                'refresh_token' => $kvs->get(self::REFRESH_TOKEN_KEY),
            ]);
        }

        $accessToken = $this->provider->getAccessToken($this->type, $accessTokenParams);
        $this->cacheToken($accessToken);

        return $accessToken;
    }
private function getToken($accessTokenParams)
    {
        $kvs = $this->getKeyValueStorage();

        if ($kvs->has(self::ACCESS_TOKEN_KEY) && $kvs->has(self::REFRESH_TOKEN_KEY)) {
            return new AccessToken([
                'access_token' => $kvs->get(self::ACCESS_TOKEN_KEY),
                'expires_in' => $kvs->getTtl(self::ACCESS_TOKEN_KEY),
                'refresh_token' => $kvs->get(self::REFRESH_TOKEN_KEY),
            ]);
        }

        $accessToken = $this->provider->getAccessToken($this->type, $accessTokenParams);
        $this->cacheToken($accessToken);

        return $accessToken;
    }
private function getToken ( $ accessTokenParams ) { $ kvs = $ this -> getKeyValueStorage ( ) ; if ( $ kvs -> has ( self :: ACCESS_TOKEN_KEY ) && $ kvs -> has ( self :: REFRESH_TOKEN_KEY ) ) { return new AccessToken ( [ 'access_token' => $ kvs -> get ( self :: ACCESS_TOKEN_KEY ) , 'expires_in' => $ kvs -> getTtl ( self :: ACCESS_TOKEN_KEY ) , 'refresh_token' => $ kvs -> get ( self :: REFRESH_TOKEN_KEY ) , ] ) ; } $ accessToken = $ this -> provider -> getAccessToken ( $ this -> type , $ accessTokenParams ) ; $ this -> cacheToken ( $ accessToken ) ; return $ accessToken ; }
Gets the access token from the cache if it exists there
or requests the new one with given credentials.

@param $accessTokenParams
@return AccessToken
Gets the access token from the cache if it exists there or requests the new one with given credentials .