> haddad_zineddine's avatar

Laravel Passport

Hello ,

i add the default authentification to my project using Laravel ui , and next i add laravel passport for api , so we need to create login and registre function ? or how we can use login and function offred by laravel ui in this case ?

0 likes
7 replies
rodrigo.pedra's avatar

so we need to create login and registre function ?

Yes. Laravel UI's login and register routes are meant to be used with session-based request and not from API.

Also, if your app does not need to serve as an OAuth server for other apps (similar to when you use "Login With Facebook", but in this case your app would play the Facebook roles on authorizing third-party apps), I highly recommend you using Laravel Sanctum instead of Laravel Passport.

Sanctum is much easier to install and configure.

https://laravel.com/docs/8.x/sanctum

Its docs even have an example where you would generate a token from an third-party call (login with API):

https://laravel.com/docs/8.x/sanctum#issuing-mobile-api-tokens

Hope it helps.

1 like
martinbean's avatar

@jokerdz Passport adds OAuth authentication to your application, so it allows first- and third-party clients to request tokens for your users, which you can then use to make API requests as that user. You don’t “log in” to an API; you use tokens to authenticate each request.

For registration, if you want to be able to register users from a first- or third-party client, then you’ll need to create an API endpoint that facilitates this. Be sure to add spam prevention measures to this endpoint though, such as rate limiting, reCAPTCHA for repeated registrations from the same device/location, etc.

1 like
martinbean's avatar

@jokerdz First party clients are things like your own mobile apps. Third party clients are exactly that: third parties that need to access your data for some reason.

Think about Facebook. When you authenticate with Facebook to get a user’s details, you do so as a third party. You don’t work for Facebook, but you’re using OAuth to retrieve data from Facebook’s servers. Whereas the Messenger app would be a first party client to Facebook, because Facebook owns and operates Messenger and its apps.

2 likes

Please or to participate in this conversation.