Please follow the below tutorial, you will have a working API authentication as a result. This applies to Laravel 5.6.
https://medium.com/modulr/create-api-authentication-with-passport-of-laravel-5-6-1dc2d400a7f
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi All,
I have a laravel backend with api routes, this api is going to be consumed by two web front ends and a mobile app using vue js. The front end doesn't require any log in to use it, however I want to authenticate the api so only my web apps and mobile app can make calls to it, what is the best way to approach this?
Thanks in advance :)
If your API will be consumed by end users, you could keep it simple and use the default auth:api middleware provided by Laravel out of the box.
Or, if there is not always a user, I would use Laravel Passport with Client Credentials grant, for machine to machine communication.
No matter what you choose, Laravel Passport got you covered. Just read the docs in Laravel or the OAuth 2.0 spec to learn more about the differents grant types and pick the best suited for your case.
Please or to participate in this conversation.