1. Go to this page and download the library: Download sopheak/sp-jwt-auth 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/ */
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Route;
use Illuminate\Validation\ValidationException;
use Sopheak\JwtAuth\DTO\TokenContext;
use Sopheak\JwtAuth\Services\JwtTokenService;
use Sopheak\JwtAuth\Support\TokenResponse;
Route::post('/login', function (Request $request, JwtTokenService $jwt) {
$credentials = $request->validate([
'email' => [''profile.read']),
);
return TokenResponse::passportCompatible($pair);
});
Route::post('/refresh', function (Request $request, JwtTokenService $jwt) {
$data = $request->validate([
'refresh_token' => ['