How to authenticate Mobile App using Laravel Sanctum & Laravel Fortify

preview_player
Показать описание
Authenticating mobile apps can be tricky because you can't use the session based authentication that Laravel Sanctum offers. Instead, we need to use a token based authentication which is also offered by Laravel Sanctum. In this video, we authenticate a react native mobile app using the existing Laravel Fortify API's backend that we used to authenticate the SPA in this series with few modifications. This allows us to keep all of fortify's features & have the ability to authenticate both mobile apps & SPAs.

🤝 You can support me by giving my videos a 👍 & by subscribing to the channel ✔️

---- Note ----

---- Source Code ----

--- Laravel Fortify Without Jetstream Series ---
Рекомендации по теме
Комментарии
Автор

8 years of watching youtube coding tutorials and this has to be one of the clearest, straight forward tutorial. Thank you Gio

VitalHipHop
Автор

Hey Gio, how would you implement a refresh token for sanctum token based authentication? I see on forums laravel passport mentioned, but I don't need the complexity. Thanks for the awesome work!

l.b
Автор

Great video Gio. I'd like to use Fortify's 2FA feature as part of the mobile app authentication flow. So... user enters their username and password, followed by their 2FA passcode, and only then is the token returned.

What would be the best way to do that?

binaryfire
Автор

Please make series with laravel + react Native. Maybe small shop wth stripe subscriptions :)

marcinmaj
Автор

Hey Gio, if we need to authenticate a 3rd party app (no user) on top of existing SPA (user) authentication to be able to consue some endpoints, can we still use Sanctum as the same approach as this one? Or this is a completely separate authentication outside of Sanctum since there is no user involved? Thank you.

joshuasabac
Автор

Will this still be working with fortify features if we didn't use session based authentication? I unintentionally made token based authentication and storing it via storage when I was in the middle of your series and it became a hot mess when I started for the 2fa. That is why I trashed that and restarted a new project file and do it all over.

Or it's just me and my newbie approach that I was not able to do it properly haha

shironekomaru
Автор

For example if laravel want to serve list of something as API/APIs for both first-party SPA and third-party SPA (or Mobiles), what is the best practice? (actually simplest and pretty clean ways)
1- Create TWO separately APIs for each SPA.
2- Create ONE API for both SPA (in this case, How do we differentiate between two requests?)

homayoonsoheyli
Автор

And what if you are using firebase auth is it the same?

dermimalika
Автор

Thank you for this tutorial. I have a mobile react-native app that was working fine, using Laravel Sanctum for API calls on the production server until I added a sub-domain to my domain. Now, I can still log in via the mobile app but every subsequent API call gives a 401 error, "Unauthenticated." Although this API call still works very well on my local machine. Please, kindly assist me.

akeemsalami
Автор

The begining of the videos or in the videos there is references to previous videos but the videos you have dont show which is which your talking about, lets say sanctum videos or fortify videos

munandisichali
Автор

I don't get the naming. Mobile authentication has nothing to do with user authentication. Mobile authentication is where you make sure only your app can access an API.

goowik
Автор

This is just showing how to authenticate your app with tokens not how to use fortify with tokens.... Very misleading

alexlytle