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
@@ -48,6 +51,17 @@ See [facebook example](./examples/facebook.js) for an example.
48
51
This fastify plugin decorates the fastify instance with the [`simple-oauth2`](https://github.com/lelylan/simple-oauth2)
49
52
instance.
50
53
54
+
## Utilities
55
+
56
+
This fastify plugin adds 2 utility decorators to your fastify instance:
57
+
58
+
-`getAccessTokenFromAuthorizationCodeFlow(request, callback)`: A function that uses the Authorization code flow to fetch an OAuth2 token using the data in the last request of the flow. If the callback is not passed it will return a promise. The object resulting from the callback call or the promise resolution is a *token response* object containing the following keys:
59
+
-`access_token`
60
+
-`refresh_token` (optional, only if the `offline scope` was originally requested)
61
+
-`token_type` (generally `'bearer'`)
62
+
-`expires_in` (number of seconds for the token to expire, e.g. `240000`)
63
+
-`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).
0 commit comments