Skip to content

Commit e8df9dc

Browse files
authored
docs: Update README.md with revised information (#207)
1 parent dfafabe commit e8df9dc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fastify.get('/login/facebook/callback', async function (request, reply) {
4343
console.log(token.access_token)
4444

4545
// if later you need to refresh the token you can use
46-
// const { token: newToken } = await this.getNewAccessTokenUsingRefreshToken(token.refresh_token)
46+
// const { token: newToken } = await this.getNewAccessTokenUsingRefreshToken(token)
4747

4848
reply.send({ access_token: token.access_token })
4949
})
@@ -227,7 +227,13 @@ This fastify plugin adds 3 utility decorators to your fastify instance using the
227227
- `refresh_token` (optional, only if the `offline scope` was originally requested, as seen in the callbackUriParams example)
228228
- `token_type` (generally `'bearer'`)
229229
- `expires_in` (number of seconds for the token to expire, e.g. `240000`)
230-
- `getNewAccessTokenUsingRefreshToken(refreshToken, params, callback)`: A function that takes a refresh token and retrieves a new `AccessToken` 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 `AccessToken` object (see above).
230+
- `getNewAccessTokenUsingRefreshToken(Token, params, callback)`: A function that takes a `AccessToken`-Object as `Token` and retrieves a new `AccessToken`-Object. This is generally useful with background processing workers to re-issue a new AccessToken when the previous AccessToken has expired. The `params` argument is optional and it is an object that can be used to pass in additional 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 resolved Promise is a new `AccessToken` object (see above). Example of how you would use it for `name:googleOAuth2`:
231+
```js
232+
fastify.googleOAuth2.getNewAccessTokenUsingRefreshToken(currentAccessToken, (err, newAccessToken) => {
233+
// Handle the new accessToken
234+
});
235+
```
236+
231237
- `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:
232238

233239
```js

0 commit comments

Comments
 (0)