Skip to content

Commit 2009b29

Browse files
authored
Clarify in the docs how to use this module with fastify-cookie (#214)
1 parent c1fb5ae commit 2009b29

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ npm i @fastify/oauth2
2121
const fastify = require('fastify')({ logger: { level: 'trace' } })
2222
const oauthPlugin = require('@fastify/oauth2')
2323

24-
2524
fastify.register(oauthPlugin, {
2625
name: 'facebookOAuth2',
2726
credentials: {
@@ -49,6 +48,19 @@ fastify.get('/login/facebook/callback', async function (request, reply) {
4948
})
5049
```
5150

51+
### Usage with `@fastify/cookie`
52+
53+
Since v7.2.0, `@fastify/oauth2` requires the use of cookies to securely implement the OAuth2 exchange. Therefore, if you need `@fastify/cookie` yourself,
54+
you will need to register it _before_ `@fastify/oauth2`.
55+
56+
```js
57+
const fastify = require('fastify')({ logger: { level: 'trace' } })
58+
const oauthPlugin = require('@fastify/oauth2')
59+
60+
fastify.register(require('@fastify/cookie'), cookieOptions)
61+
fastify.register(oauthPlugin, oauthOptions)
62+
```
63+
5264
### Preset configurations
5365

5466
You can choose some default setup to assign to `auth` option.

0 commit comments

Comments
 (0)