Currently I am building rest API using Laravel. For authentication, I am using the Sanctum package. Every time a user is logged in it generate a token that looks like this:
"token": "98|b45h97e17VVpugjO71wwURoicIqDQP2ejTkCWwoD"
But why Sanctum includes the database id with the token?

How to remove the database id from the token?
I just looked through the source history and found that the ID was introduced in a well-named commit called more performant tokens lookup, so that is the reason the ID is part of the token.
But if you look at the code loading/verifying the token there is a fallback at the beginning in case there is no ID. So you can simply remove it from the token, for example by overriding the findToken method.
try this,
Option 1:-
In Controller:-
$token = $user->createToken(''project_name')->plainTextToken;
$auth_token = explode('|', $token)[1];
Option 2:-
In postman Refer image:-

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With