PHP code example of laranex / laravel-refresh-token
1. Go to this page and download the library: Download laranex/laravel-refresh-token library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laranex / laravel-refresh-token example snippets
return [
/*
|--------------------------------------------------------------------------
| Encryption Keys
|--------------------------------------------------------------------------
|
| Refresh Token uses encryption keys while generating secure access tokens for
| your application. By default, the keys are stored as local files but
| can be set via environment variables when that is more convenient.
|
*/
'private_key' => env('REFRESH_TOKEN_PRIVATE_KEY'),
'public_key' => env('REFRESH_TOKEN_PUBLIC_KEY'),
/*
|--------------------------------------------------------------------------
| Refresh Token Model
|--------------------------------------------------------------------------
|
| Refresh Token Model to manage refresh tokens
|
*/
'model' => RefreshToken::class,
/*
|--------------------------------------------------------------------------
| Refresh Token Table
|--------------------------------------------------------------------------
|
| Refresh Token Model to manage refresh tokens
|
*/
'table' => 'laravel_refresh_tokens',
];
class User extends Authenticatable{
use HasRefreshTokens;
}
$user = Auth::user()->createRefreshToken();
$verifiedToken = Laranex\RefreshToken\RefreshToken::tokenable($request->get('refresh_token'));
if ($verifiedToken) {
// Implement your access token logic here
} else {
// handle invalid refresh token
}