Skip to main content
Quick Tip

Get Bearer Token from Authorization header

The bearerToken() function is very handy when you are working with apis & want to access the token from Authorization header.

// Don't parse API headers manually like this:
$tokenWithBearer = $request->header('Authorization');
$token = substr($tokenWithBearer, 7);
 
//Do this instead:
$token = $request->bearerToken();

Tip given by @iamharis010

Enjoyed This Tip?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Recent Courses

Queues in Laravel 13

18 lessons
1 h 12 min read

Livewire v3 to v4: Changes You Need to Know

7 lessons
31 min

Laravel Coding with AI Agents: Cursor, Claude Code, Codex

5 lessons
1 h 01 min

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.