oauth2-server/auth-server-refresh-token.md

27 lines
1.1 KiB
Markdown
Raw Normal View History

2014-10-01 03:14:18 +05:30
---
layout: default
title: Authorization server with refresh token grant
permalink: /authorization-server/refresh-token-grant/
---
# Authorization server with refresh token grant
## Setup
Wherever you intialise your objects, initialize a new instance of the authorization server and bind the storage interfaces and authorization code grant:
~~~ php
$server = new \League\OAuth2\Server\AuthorizationServer;
$server->setSessionStorage(new Storage\SessionStorage);
$server->setAccessTokenStorage(new Storage\AccessTokenStorage);
$server->setClientStorage(new Storage\ClientStorage);
$server->setScopeStorage(new Storage\ScopeStorage);
2014-10-16 16:35:46 +05:30
$server->setRefreshTokenStorage(new Storage\RefreshTokenStorage);
2014-10-01 03:14:18 +05:30
2014-10-16 16:37:13 +05:30
$refreshTokenGrant = new \League\OAuth2\Server\Grant\RefreshTokenGrant();
$server->addGrantType($refreshTokenGrant);
2014-10-01 03:14:18 +05:30
~~~
2014-10-16 16:37:13 +05:30
When the refresh token grant is enabled, a refresh token will automatically be created with access tokens issued requested using the [authorization code](/authorization-server/auth-code-grant/) or [resource owner password credentials](/authorization-server/resource-owner-password-credentials-grant/) grants.