@yisusvzq A client uses a client ID and secret to request access tokens. An access token is then used to access your API and also identify the user making the request.
API and users Auth: best practices with Lumen Passport
Hi everyone,
I'm currently developing a tiny and simple API with Lumen. I need to implement authentication for users, but I would also like to have control of the applications that are requesting my API.
This is the case: I'm having two kind of routes:
- The ones that require the user to be logged in, with a valid Bearer token in the Header of the request. I have this working nicely right now with Lumen Passport.
- The ones that will not require the user to be logged. In fact, I don't need to make any reference to users.
Both kind of routes will be reachable by a Front and a Mobile App. I don't want anyone else to be able to request my API, so I was thinking on some kind of client authorization with Passport.
The thing is that I can't think of a way to combine both auth's. I don't even know how to check that only certain clients are going to be able to reach my endpoints, and others will get a 401.
The first idea that came to my mind was giving them the client_id and client_secret created when running
php artisan passport:install
but I don't know how to check them in a middleware. I'm pretty sure it's quite simple, but I'm stuck.
I'd appreciate any hint. Thanks a lot in advance!!
Sorry for the late answer. I eventually understood better OAuth in part thanks to oauth.com where I could find and read about the different servers.
Thank you all for you answers.
Please or to participate in this conversation.