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
Wrap around [`simple-oauth2`](https://github.com/lelylan/simple-oauth2) library.
8
+
Wrapper around the[`simple-oauth2`](https://github.com/lelylan/simple-oauth2) library.
6
9
7
10
v4.x of this module support Fastify v3.x
8
11
[v3.x](https://github.com/fastify/fastify-oauth2/tree/3.x) of this module support Fastify v2.x
@@ -63,7 +66,7 @@ You can choose some default setup to assign to `auth` option.
63
66
64
67
### Custom configuration
65
68
66
-
Of course you can set the OAUTH endpoints by yourself if a preset is not in our module:
69
+
Of course, you can set the OAUTH endpoints by yourself if a preset is not in our module:
67
70
68
71
```js
69
72
fastify.register(oauthPlugin, {
@@ -157,7 +160,7 @@ See the [`example/`](./examples/) folder for more example.
157
160
158
161
## Reference
159
162
160
-
This fastify plugin decorates the fastify instance with the [`simple-oauth2`](https://github.com/lelylan/simple-oauth2)
163
+
This Fastify plugin decorates the fastify instance with the [`simple-oauth2`](https://github.com/lelylan/simple-oauth2)
161
164
instance inside a **namespace** specified by the property `name`.
162
165
163
166
E.g. For `name: 'customOauth2'`, the `simple-oauth2` instance will become accessible like this:
@@ -189,8 +192,8 @@ This fastify plugin adds 3 utility decorators to your fastify instance using the
189
192
-`refresh_token` (optional, only if the `offline scope` was originally requested)
190
193
-`token_type` (generally `'bearer'`)
191
194
-`expires_in` (number of seconds for the token to expire, e.g. `240000`)
192
-
-`getNewAccessTokenUsingRefreshToken(refreshToken, params, callback)`: A function that takes a refresh token and retrieves a new *token response* object. This is generally useful with background processing workers to re-issue a new token when the original token has expired. The `params` argument is optional and it's an object that can be used to pass in extra parameters to the refresh request (e.g. a stricter set of scopes). If the callback is not passed this function will return a promise. The object resulting from the callback call or the promise resolution is a new *token response* object (see fields above).
193
-
-`generateAuthorizationUri(requestObject)`: A function that returns the authorization uri. This is generally useful when you want to handle the redirect yourself in a specific route. The `requestObject` argument passes the request object to the `generateStateFunction`). You **don't** need to declare a `startRedirectPath` if you use this approach. Example of how you would use it:
195
+
-`getNewAccessTokenUsingRefreshToken(refreshToken, params, callback)`: A function that takes a refresh token and retrieves a new *token response* object. This is generally useful with background processing workers to re-issue a new token when the original token has expired. The `params` argument is optional and it is an object that can be used to pass in extra parameters to the refresh request (e.g. a stricter set of scopes). If the callback is not passed this function will return a promise. The object resulting from the callback call or the promise resolution is a new *token response* object (see fields above).
196
+
-`generateAuthorizationUri(requestObject)`: A function that returns the authorization uri. This is generally useful when you want to handle the redirect yourself in a specific route. The `requestObject` argument passes the request object to the `generateStateFunction`). You **do not** need to declare a `startRedirectPath` if you use this approach. Example of how you would use it:
194
197
195
198
```js
196
199
fastify.get('/external', { /* Hooks can be used here */ }, async (req, reply) => {
@@ -204,9 +207,9 @@ E.g. For `name: 'customOauth2'`, the helpers `getAccessTokenFromAuthorizationCod
Type definitions are provided with package. Decoration are applied during runtime and are based on auth configuration name. One solution is leverage typescript declaration merging to add type-safe namespace.
212
+
Type definitions are provided with the package. Decorations are applied during runtime and are based on auth configuration name. One solution is to leverage TypeScript declaration merging to add type-safe namespace.
0 commit comments