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

garrettmassey's avatar

Authenticating users connecting to a Laravel API

I know that Laravel has pretty robust support for API development, but I haven't really used it in the past. Now I'm working on a project that uses Laravel as the backend and API provider for a mobile application that uses and sends data over the API's endpoints.

I normally would use Breeze to do simple authentication for web apps, but I am unsure how to get started on authenticating users on an API.

So let's say I build an iOS app that communicates with a Laravel API, but there's also a web version. The web version uses Breeze for simple authentication. How would I go about authenticating users over the API? How would I remember them on that device?

Passport seems like the likely solution to this problem, but honestly I don't know enough about oAuth2 and I don't really understand how it's different or implemented, and I couldn't find anything as an "introduction" here on Laracasts.

So, any resources to help someone who is just learning how to work with authenticating users over an API in Laravel?

0 likes
4 replies
lara230832's avatar

You should check the Laravel Sanctum Package documentation on the Laravel site. Think this is what you are looking for.

garrettmassey's avatar

@JeffreyvR It looks like Sanctum is a lot more streamlined than Passport, which is what I thought I would need to use, so I'll definitely read through the docs for Sanctum, thanks!

Please or to participate in this conversation.