question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getToken throws an error

See original GitHub issue

Describe the bug After updating to 3.15.5 the following code throws an error

export default async function TruAPIHandler(
  req: NextApiRequest,
  res: NextApiResponse,
) {
  // getToken will throw
  const token = await getToken({
    req,
    secret: process.env.NEXTAUTH_SECRET,
    encryption: true,
    signingKey: process.env.NEXTAUTH_SIGNIN_KEY,
    encryptionKey: process.env.NEXTAUTH_ENCRYPTION_KEY,
  })

Steps to reproduce I’m using an encrypted JWT in my configuration

  secret: process.env.NEXTAUTH_SECRET,
  session: {
    jwt: true,
  },
  jwt: {
    encryption: true,
    secret: process.env.NEXTAUTH_SECRET,
    signingKey: process.env.NEXTAUTH_SIGNIN_KEY,
    encryptionKey: process.env.NEXTAUTH_ENCRYPTION_KEY,
  },

Simple repo to reproduce https://github.com/mtt87/next-auth-bug

Expected behavior It should not throw an error and return the token as it happens correctly on 3.14.8

Screenshots or error logs

TypeError: Object(...) is not a function
    at TruAPIHandler (webpack-internal:///./pages/api/tru/[...params].ts:9:85)
    at apiResolver (/Users/mattia/node_modules/next/dist/next-server/server/api-utils.js:8:7)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async DevServer.handleApiRequest (/Users/mattia/node_modules/next/dist/next-server/server/next-server.js:67:462)
    at async Object.fn (/Users/mattia/node_modules/next/dist/next-server/server/next-server.js:59:492)
    at async Router.execute (/Users/mattia/node_modules/next/dist/next-server/server/router.js:25:67)
    at async DevServer.run (/Users/mattia/node_modules/next/dist/next-server/server/next-server.js:69:1042)
    at async DevServer.handleRequest (/Users/mattia/node_modules/next/dist/next-server/server/next-server.js:34:504)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
balazsorban44commented, Apr 22, 2021

The problem was something else, but I now verified locally that the new release fixed the problem!

0reactions
github-actions[bot]commented, Apr 23, 2021

🎉 This issue has been resolved in version 4.0.0-next.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

[firebase_messaging] getToken() throws an exception in some ...
When running integration tests on Firebase Test Lab however, the call to getToken() sometimes throws an error and we have no idea why....
Read more >
and FirebaseMessaging.instance.getToken() throws android ...
I found the issue. I'm living in Syria, and it has become forbidden to call getToken for the first time without a VPN,...
Read more >
3036327 - Error "The request is malformed" throws when get ...
When try to get OAuth 2.0 token against AS Java, it end with error "The request is malformed". For example: When use Postman...
Read more >
FirebaseMessaging.instance.getToken() throws ... - Reddit
By the way in IOS app works perfectly. When I try to get token it throws this error: E/FirebaseMessaging(21291): Failed to get FIS...
Read more >
getToken() works in ASP.NET but throws Authentication error ...
I am able to get a token and receive messages when I use ASP.NET but when I try the same code in Vue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found