Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

331
Visualizações
Nextjs plus nextauth no puede configurar jwt

Estoy tratando de configurar JWT con NextAuth y es solo un dolor, leer publicaciones en GitHub e investigar no me devuelve ninguna ayuda. Tengo la sensación de que está ocurriendo un error cuando NextAuth intenta decodificar la carga útil de JWT, solo estoy tratando de devolver una cadena de números que se devuelven desde Twitch al iniciar sesión, necesito esto para usar en una llamada API a Twitch.

Soy nuevo en JWT y NextAuth, ¡así que no soy un profesional!

repositorio de github para todo el proyecto https://github.com/MatWebsites/next-auth-example-main

¡Cualquier ayuda sería enorme!

 // console errors unhandledRejection: TypeError: Cannot read properties of undefined (reading 'next-auth.session-token') - error - Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead. - TypeError: getCurves is not a function -

página de error nextjs error

 //[...nextauth].js import NextAuth from "next-auth" import Providers from "next-auth/providers" export default NextAuth({ providers: [ Providers.Twitch({ clientId: process.env.TWITCH_CLIENT_ID, clientSecret: process.env.TWITCH_CLIENT_SECRET, }), Providers.Spotify({ clientId: process.env.SPOTIFY_CLIENT_ID, clientSecret: process.env.SPOTIFY_CLIENT_SECRET }), ], secret: process.env.SECRET, session: { jwt: true, }, // https://next-auth.js.org/configuration/options#jwt jwt: { // A secret to use for key generation (you should set this explicitly) secret: process.env.SECRET, // Set to true to use encryption (default: false) // encryption: true, // You can define your own encode/decode functions for signing and encryption // if you want to override the default behaviour. // encode: async ({ secret, token, maxAge }) => {}, // decode: async ({ secret, token, maxAge }) => {}, }, callbacks: { async signIn(user, account, profile) { return true }, // async redirect(url, baseUrl) { return baseUrl }, async session(session, user) { return session }, async jwt(token, user, account, profile, isNewUser) { token.accessToken = account.access_token; return token } }, theme: 'light', debug: true, })
 //test.js - trying to decode and use the data inside the web token import { getToken } from 'next-auth/jwt' const secret = process.env.SECRET const test = (req, res) => { const token = getToken({req, secret}); return ( <div> <a>{token.sub}</a> // Should show the users id returned from Twitch </div> ) } export default test
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

getToken devuelve una promesa. Tienes que await antes de hacer cualquier operación en él.

 const test = async (req, res) => { const token = await getToken({req, secret}); return ( <div> <a>{token.sub}</a> // Should show the users id returned from Twitch </div> ) }
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda