Loading Page

In this tutorial I'll cover how to setup JSON Web Token authentication using Laravel and Vue JS. The tutorial will have two parts. The first part will cover setting up Laravel to generate JSON Web Tokens. The second part gets a little more interesting as it covers authentication using Vue JS in the context of an SPA.

The approach here is different to what the Laravel documentation covers. The Laravel Passport feature is an OAuth2 implementation.

The latest version of Laravel at the time of writing is v5.5 so if you are using another version things may be slightly different.

Setting up JSON Web Token authentication with Laravel

To generate JSON Web tokens from the Laravel backend we'll be using the popular library tymondesigns/jwt-auth by Sean Tymon.

I’ve reproduced the steps from the documentation by Sean with a couple of minor tweaks I made to get around issues I ran into with the installation and to hopefully help readers with a couple of minor gotchas. The documentation can be found here:


Install the library. I've included the latest version in the command. Without including the version number, on my machine composer installed version 0.5.

composer require tymon/jwt-auth:1.0.0-rc.1

Publish the configuration file. This creates a config/jwt.php config file.

Source: Part 1

You Might Also Like