Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mostromhall's avatar

API Authentication with no user

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 :)

0 likes
4 replies
claudsonm's avatar
Level 28

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.

1 like
mostromhall's avatar

Perfect thank you, the client credentials grant looks exactly like what I need :)

mostromhall's avatar

@claudsonm I've been reading into this and have come across a problem, my front end uses Vue js so all calls to the api are through axios not in php, how do I make the client credentials grant request securely?

1 like

Please or to participate in this conversation.