bshaffer / oauth2-server-php-docs

documentation for the oauth2-server-php library
231 stars 148 forks source link

Storage/Memory simple question #105

Closed luanmanfre closed 6 years ago

luanmanfre commented 6 years ago

Is possible create a server jwt using only memory storage? Because, I can not read the refresh token in memory. how is the $server->addGrantType( OAuth2\GrantType\RefreshToken ) in memory, for after so that I can then make a call to create a new access_token, all using Storage/Memory. Its possible?

ignore this structure of code

server.php $storage = new OAuth2\Storage\Memory(...) $server = new OAuth2\Server($storage)

method: token(){ return access_token, jwt and others  }
method: resource(){ if user is valid and show resource...}
method: renewRefreshToken(){  here.. i need the idea for code }

in PDO storage, works with me.. but I want to test in memory.

Thanks

bshaffer commented 6 years ago

Sorry, I don't quite understand the question. What exactly are you trying to do?

luanmanfre commented 6 years ago

http://bshaffer.github.io/oauth2-server-php-docs/grant-types/refresh-token/ in memory.. first add a client then a user then I'm going to test generate a new access_token from the refresh that came in the query and returns me invalid

luanmanfre commented 6 years ago

ok, i solved it.

$this->storage->setRefreshToken("refresh_token", "client_id", "user_id", strtotime("timestamp"));
$grantType = new OAuth2\GrantType\RefreshToken($this->storage, array(
    'always_issue_new_refresh_token' => true,
    'unset_refresh_token_after_use' => true)
);
$this->server->addGrantType($grantType);