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

HUGE_DICK_10_INCHES's avatar

How to properly use api auth with passport

I am wondering is using auth()->user() usable with passport auth?

Currently I am using attempt method for login and on localhost I had no problem but on server I needed to add to use web instead of api to work with it. Now I am wondering is that right anyway?

Since I don't use session and cookies, when I send bearer token through headers does it directly check within database and then store User within auth()->user() or how does it work?

0 likes
1 reply
martinbean's avatar

@skycoder Passport uses the bearer token to look up the user associated with that token, so long as the token is valid and youre using the correct guard (usually api).

Please or to participate in this conversation.