You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+101-5
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,3 @@
1
-
2
-
3
1
# Laravel HTTP Client Auth helper
4
2
5
3
An easy-to-use helper for Laravel HTTP Client to make manage API requests with a two-step auth flow.
@@ -13,6 +11,13 @@ This helper takes care of all the headaches and boilerplate code with a simple a
13
11
- Extends the Laravel HTTP Client to make it straightforward to use. Se the [usage section](#usage) below for examples.
14
12
- Supports common auth flows like OAuth2 and refresh tokens with most grant types.
15
13
14
+
#### Vision, roadmap & plans for the future
15
+
16
+
I want to support as many common auth flows as possible.\
17
+
If you have a use case that is not super obscure,
18
+
please [open an issue](https://github.com/pelmered/laravel-http-client-auth-helper/issues/new) where you provide as much detail as possible,
19
+
or [submit a PR](https://github.com/pelmered/laravel-http-client-auth-helper/pulls).
20
+
16
21
#### Note: the API is not yet stable and the documentation is in the process of being updated. I hope I can release a version 1 soon.
17
22
18
23
#### TODO before stable 1.0.0 version:
@@ -41,6 +46,33 @@ This helper takes care of all the headaches and boilerplate code with a simple a
41
46
[](https://github.com/pelmered/filament-money-field/actions/workflows/tests.yml)
42
47
[](https://github.com/pelmered/laravel-http-client-auth-helper/actions/workflows/tests.yml)
43
48
49
+
<!-- toc -->
50
+
51
+
-[Requirements](#requirements)
52
+
-[Vision, roadmap & plans for the future](#vision-roadmap--plans-for-the-future)
**Possible options:**`Credentials::GRANT_TYPE_CLIENT_CREDENTIALS`, `Credentials::GRANT_TYPE_PASSWORD_CREDENTIALS` (authorization_code and implicit grants are not yet supported. See [issue #3](https://github.com/pelmered/laravel-http-client-auth-helper/issues/3))
The name of the token field. This only applies for when the token is applied as a query parameter or to the body of the request.
129
+
**Possible options:** Any string
130
+
**Default:**`'token'`
131
+
132
+
#### expires - `int|string|Closure|Carbon`
133
+
This determines when the access token expires.\
134
+
**Possible options:**\
135
+
integer - for how long until expiry in seconds)\
136
+
string - Can be key of the field in response that contains the expiry of the token. Can also be a string with a date. This is then parsed by Carbon::parse so any format that Carbon can parse is acceptable.\
137
+
Closure - A closure that receives the refresh response and can return any other acceptable value (integer, string or Carbon object).\
138
+
Carbon - A Carbon object with the time of the expiry.\
139
+
**Default:** 3600
140
+
141
+
#### accessToken - `string|Closure`
142
+
This is where the access token can be found on the refresh response.\
143
+
**Possible options:**\
144
+
string - The key of the access token in the refresh response.\
145
+
Closure - A closure that receives the refresh response and should return the token as a string.\
146
+
**Default:**`'access_token'`
147
+
148
+
#### tokenTypeCustomCallback - `?Closure`
149
+
A callback for giving dull control of how the authentication should be applied.
150
+
The closure receives the Http client and should return a new Http Client where the auth information has been appended.\
151
+
**Possible options:**\ Any closure that returns a Http Client (`Illuminate\Http\Client\PendingRequest`).\
152
+
**Default:**`null`
153
+
154
+
#### cacheKey - `?string`
155
+
The cache key that should be used to save the access tokens.
156
+
If left empty, it will be generated based on the refresh URL.\
157
+
**Possible options:**\
158
+
**Default:**`null`
159
+
160
+
#### cacheDriver - `?string`
161
+
The cache driver/store that should be used for storing the access tokens.
162
+
If left empty, the Laravel default will be used.\
163
+
**Possible options:**\
164
+
**Default:**`null`
165
+
71
166
## Usage
72
167
73
168
It's really simple to use. Just add the `withRefreshToken` method to your HTTP request and provide the necessary parameters. No configuration needed.
0 commit comments