fastify / fastify/fastify-oauth2
Apple OAuth2 example doesn't work
- Dominant language
- JavaScript
- Stars
- 319
- Forks
- 74
- Avg merge
- 7h 16m
- Merged PRs (30d)
- 1
Description
### Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the bug has not already been reported
### Fastify version
4.26.1
### Plugin version
7.8.0
### Node.js version
v20.6.1
### Operating system
Windows
### Operating system version (i.e. 20.04, 11.3, 10)
10
### Description
I created the issue, so that it clarifies the issue or helps other people.
I had to make changes to make the example work. `examples/apple.js`
Explicitly setting scope to empty (otherwise undefined error) `scope: [], //'name', 'email'` , when I set scope apple returns POST form-urlencoded. That is documented in the example and Github issues. It might be nice to provide an example for that case as well.
`const { code, state, error, user } = request.query` instead of `request.body`
Wher does `Error.CancelledAuth` comes from? It is undefined so it has wrong logic when error is also undefined.
The part I didn't understand:
`request.cookies['oauth2-redirect-state']` this is empty, however the cookie is set in browser dev tools.
Readme states, "Since v7.2.0, @fastify/oauth2 requires the use of cookies to securely implement the OAuth2 exchange." It is after this example is updated on the repo.
### Steps to Reproduce
Create a new project `npm init fastify` and try `examples/apple.js` example
### Expected Behavior
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.