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

smnwk's avatar
Level 1

Laravel's Passport + Testing

Hi there,

I'm using Laravel's Passport to build an api backend. I implemented the CreateFreshApiToken class to consume the api with JavaScript; this works. But now I want to test my api in Postman - what's the best practice getting the Bearer attribute?

I've tried $request->bearerToken()but I only get null.

0 likes
3 replies
tykus's avatar

If bearerToken is null then there is no token being passed in the Authorization header that begins with 'Bearer '.

In Postman, you can set the Bearer token using the Authorization tab, select Bearer Token in the Type dropdown, and paste your token in the Token field.

smnwk's avatar
Level 1

Hi, but the axios request works?

tykus's avatar

Hi, but the axios request works?

And? Postman is a different client. You must send a token if you want to authenticate the request; I have described how to do this in Postman above.

Please or to participate in this conversation.