This project has been archived. If you're curious, check out one of my latest courses:

If you work with JavaScript, check out the fetch use cases and JavaScript projects.

Thank you! — Jad Joubran

JWT Auth Usage

Using the JWT Auth Guard


In order to protect a certain route with the JWT Auth Guard, you need to specify auth:api as a middleware. Just like the example already present in your routes/api.php.

Creating tokens

You can create a token by attempting to login with user's credentials.

$token = Auth::attempt(['email' => '[email protected]', 'password' => 'secret']);

Checking for authentication

You can check whether the user is authenticated

if (Auth::check()) {

or not

if (Auth::guest()) {

Get Authenticated User

You can get the authenticated user

$user = Auth::user();

Explore the full documentation.