-
Notifications
You must be signed in to change notification settings - Fork 25
Storage Adapaters
A storage adapter provides a different means of storing clients, scopes, and access tokens on your server. By default the following storage adapters are available:
The MySQL adapter uses PDO to connect and perform operations on the database. To get an instance of this adapter you must pass a PDO connection instance as the first parameter.
$storage = new Dingo\OAuth2\Storage\MySqlAdapter(new PDO('mysql:host=localhost;dbname=oauth', 'root'));
The Redis adapter uses Predis to perform the storage operations. To get an instance of this adapter you must pass a Predis client instance as the first parameter.
$storage = new Dingo\OAuth2\Storage\PredisAdapter(new Predis\Client);
The following packages also provide their own storage adapters:
All adapters can have the tables that are used customized. To customize the tables a second parameter must be given to the adapters constructor. This parameter must be an array of table names with identifying keys.
Your custom tables are merged with the default tables, represented by the following array.
$tables = [
'clients' => 'oauth_clients',
'client_endpoints' => 'oauth_client_endpoints',
'tokens' => 'oauth_tokens',
'token_scopes' => 'oauth_token_scopes',
'authorization_codes' => 'oauth_authorization_codes',
'authorization_code_scopes' => 'oauth_authorization_code_scopes',
'scopes' => 'oauth_scopes'
];
As an example, a customized clients
table for the MySQL adapter would look something like this:
$pdo = new PDO('mysql:host=localhost;dbname=oauth', 'root');
$storage = new Dingo\OAuth2\Storage\MySqlAdapter($pdo, [
'clients' => 'custom_oauth_clients'
]);