nextauthjs / nextauthjs/next-auth

Official website demo couldn't signin with apple

Open
#12,883 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug providers triage
Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

Provider type

Apple

Environment
System:
    OS: macOS 15.3.2
    CPU: (14) arm64 Apple M4 Pro
    Memory: 765.44 MB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.7 - ~/.nvm/versions/node/v18.20.7/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.7/bin/yarn
    npm: 10.8.2 - ~/.nvm/versions/node/v18.20.7/bin/npm
    pnpm: 9.2.0 - ~/Library/pnpm/pnpm
    bun: 1.2.5 - ~/.bun/bin/bun
  Browsers:
    Chrome: 135.0.7049.95
    Safari: 18.3.1
Reproduction URL

https://github.com/georgezouq/next-auth

Describe the issue

On my nextjs project, I have "PKCE code_verifier cookie missing" problem use apple provide, and I find official demo in next-auth website still couldn't signin with apple!

In my local, it report an error:

error: TypeError: PKCE code_verifier cookie was missing.
at Object.use (/Users/georgezou/Documents/WORK/StaringAI/mtbird-saas/node_modules/next-auth/core/lib/oauth/checks.js:60:30)
at oAuthCallback (/Users/georgezou/Documents/WORK/StaringAI/mtbird-saas/node_modules/next-auth/core/lib/oauth/callback.js:75:24)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.callback (/Users/georgezou/Documents/WORK/StaringAI/mtbird-saas/node_modules/next-auth/core/routes/callback.js:45:11)
at async AuthHandler (/Users/georgezou/Documents/WORK/StaringAI/mtbird-saas/node_modules/next-auth/core/index.js:260:28)
at async NextAuthApiHandler (/Users/georgezou/Documents/WORK/StaringAI/mtbird-saas/node_modules/next-auth/next/index.js:18:19)
at async auth (webpack-internal:///(api)/./src/pages/api/auth/next/[...nextauth].ts:26:12)
at async Object.apiResolver (/Users/georgezou/Documents/WORK/StaringAI/mtbird-saas/node_modules/next/dist/server/api-utils/node.js:366:9)
at async DevServer.runApi (/Users/georgezou/Documents/WORK/StaringAI/mtbird-saas/node_modules/next/dist/server/next-server.js:481:9)
at async Object.fn (/Users/georgezou/Documents/WORK/StaringAI/mtbird-saas/node_modules/next/dist/server/next-server.js:741:37) {
name: 'OAuthCallbackError',
code: undefined
},
providerId: 'apple'
}

And I add or remove cookies blow what https://github.com/nextauthjs/next-auth/issues/9990#issuecomment-2496222713 said, it doesn't work

pkceCodeVerifier: {
            name: `${COOKIE_PREFIX}next-auth.pkce.code_verifier`,
            options: {
              httpOnly: true,
              sameSite: 'lax',
              path: '/',
              secure: true,
              maxAge: COOKIES_LIFE_TIME,
            },
          },
How to reproduce

open https://next-auth-example.vercel.app/ -> click Sign In button -> click Apple
I got this error

Expected behavior

signin in like other oauth provider

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure from https://next-auth-example.vercel.app/ by choosing Apple sign-in, then trace the reported PKCE code_verifier cookie error through the callback stack. Review the pkceCodeVerifier cookie configuration and the linked cookie discussion. Done means Apple sign-in completes successfully on the official demo like the other OAuth providers.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, node.js, typescript
Domain
authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.