Level 4
It's depends on your current guard (config/auth.php) -> web, api or custom.
You can do like this
$user = auth('api')->user();
$id = auth('api')->id();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can I get the Auth:id of the authorised API user?
I'm using Laravel Passport ,and so the user is authorised for the API by the Token ...
But I want to return only the data that is "owned" by that userid ...
So, how can I get that userid when they access the the API with a token?
It's depends on your current guard (config/auth.php) -> web, api or custom.
You can do like this
$user = auth('api')->user();
$id = auth('api')->id();
Please or to participate in this conversation.