Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twitter oauth2.0 callback error #12398

Open
mackieq opened this issue Dec 18, 2024 · 0 comments
Open

twitter oauth2.0 callback error #12398

mackieq opened this issue Dec 18, 2024 · 0 comments
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@mackieq
Copy link

mackieq commented Dec 18, 2024

Environment

  System:
    OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 5.62 GB / 15.34 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
    npm: 9.9.4 - ~/cgent/front-end/next-auth-example/node_modules/.bin/npm
    pnpm: 9.14.4 - ~/.nvm/versions/node/v20.18.0/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.139
  npmPackages:
    next: 15.0.3 => 15.0.3 
    next-auth: ^4.24.11 => 4.24.11 
    react: ^18.2.0 => 18.3.1 

Reproduction URL

https://github.com/mackieq/next-auth-example

Describe the issue

Twitter login:

  1. Step 1: Construct an Authorize URL. (correct)
  2. Step 2: GET oauth2/authorize (correct)

after step 2, twitter redirect to http://localhost:3000/api/auth/callback/twitter?state=xxx&code=xxx

My nextjs console output error:


[next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error this.getName is not a function {
  error: Error [OAuthCallbackError]: this.getName is not a function
      at async AppRouteRouteModule.do (webpack://next/dist/src/server/route-modules/app-route/module.ts:529:14)
      at async AppRouteRouteModule.handle (webpack://next/dist/src/server/route-modules/app-route/module.ts:658:30)
      at async doRender (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/base-server.ts:2504:29)
      at async responseGenerator (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/base-server.ts:3027:21)
      at async DevServer.renderToResponseWithComponentsImpl (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/base-server.ts:3039:23)
      at async DevServer.renderPageComponent (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/base-server.ts:3597:15)
      at async DevServer.renderToResponseImpl (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/base-server.ts:3659:23)
      at async DevServer.pipeImpl (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/base-server.ts:1698:20)
      at async NextNodeServer.handleCatchallRenderRequest (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/next-server.ts:1034:6)
      at async DevServer.handleRequestImpl (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/base-server.ts:1462:8)
      at async (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/dev/next-dev-server.ts:514:13)
      at async Span.traceAsyncFn (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/trace/trace.ts:143:13)
      at async DevServer.handleRequest (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/dev/next-dev-server.ts:512:19)
      at async invokeRender (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/lib/router-server.ts:284:10)
      at async handleRequest (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/lib/router-server.ts:530:15)
      at async requestHandlerImpl (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/lib/router-server.ts:576:6)
      at async Server.requestListener (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/src/server/lib/start-server.ts:146:6)
    527 |         }
    528 |       } else {
  > 529 |         res = await workUnitAsyncStorage.run(
        |              ^
    530 |           requestStore,
    531 |           handler,
    532 |           request, {
    code: undefined
  },
  providerId: 'twitter',
  message: 'this.getName is not a function'
}

It seems like a certain field is missing or has an issue when fetching the user information.

How to reproduce

down load https://github.com/mackieq/next-auth-example, config twitter clientId and secret, then:

npm install
npm run dev

Expected behavior

login callback success

@mackieq mackieq added bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Dec 18, 2024
@mackieq mackieq changed the title twitter callback api error twitter callback error Dec 18, 2024
@mackieq mackieq changed the title twitter callback error twitter oauth2.0 callback error Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

1 participant