Skip to content

Commit f3661cb

Browse files
committed
Adding example of Authorization header
1 parent c39b2a2 commit f3661cb

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,34 @@ composer require treblle/treblle-api-tools-laravel
3434

3535
## Usage
3636

37-
Coming soon ...
37+
### Headers
38+
39+
#### Authorization
40+
41+
You can use the Authorization Header can be used like the following:
42+
43+
```php
44+
use Treblle\Tools\Http\Enums\Headers\AuthScheme;
45+
use Treblle\Tools\Http\Headers\Authorization;
46+
47+
$auth = new Authorization(
48+
type: AuthScheme::BEARER,
49+
credentials: 'YOUR_API_TOKEN_HERE',
50+
);
51+
52+
// Turn the header into an array
53+
$array = $auth->toArray();
54+
//[
55+
// 'type' => AuthScheme::BEARER,
56+
// 'credentials' => 'YOUR_API_TOKEN_HERE'
57+
//]
58+
59+
// Turn the header into a header
60+
$header = $auth->toHeader();
61+
//[
62+
// 'Authorization' => 'Bearer YOUR_API_TOKEN_HERE',
63+
//]
64+
```
3865

3966
## Support
4067

0 commit comments

Comments
 (0)