oauth2-server-php icon indicating copy to clipboard operation
oauth2-server-php copied to clipboard

Specify different access_lifetime depending on grant type

Open monteduro opened this issue 11 years ago • 2 comments

is it possible to change access_lifetime for client_credential grant type only?

i've tried a lot of combination, like setting the config array for addGrantType, but it still use the main value (default 3600).

monteduro avatar May 03 '15 00:05 monteduro

inserting this snippet in request process solve the problem

$request = OAuth2\Request::createFromGlobals();
if (isset($request->request['grant_type']) && $request->request['grant_type'] == "client_credentials")
    $server->setConfig('access_lifetime', 3600*24);

monteduro avatar May 03 '15 00:05 monteduro

good recommendation - I like this solution.

The only other solution I can think of would involve subclassing both OAuth2\GrantType\ClientCredentials and OAuth2\ResponseType\AccessToken. We could add a $config['access_lifetime'] parameter to each GrantType which defaults to null, and if set would override the access_lifetime parameter. I'm not crazy about this solution, but if this feature is something people want, I will consider it.

bshaffer avatar May 04 '15 23:05 bshaffer