Http::withToken in Laravel

Опубликовано: 19 Июнь 2026
на канале: Metaphorically Speaking
745
16

In ‪@LaravelPHP‬ you can add headers to your http requests if the api you are calling requires authentication. While you can certainly add the Authorization header manually - there is a handy shortcut: withToken.

Using the withToken method will automatically set the Authorisation header and use the passed value as the Bearer token.

---

Website: https://acairns.co.uk
Twitter:   / andrewcairns  
Patreon:   / metaphoricallyspeaking  
Discord: https://acairns.co.uk/discord
Substack: https://acairns.substack.com