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

294
Visualizações
Authentication not working with Supabase and Node.js

I am not sure even this is possible but I am trying to use Supabase with Node.js. I get the code from a React front-end, this link, which works okay.

Below is my code

client.js

const { createClient } = require('@supabase/supabase-js')

const supabaseUrl = "MY_URL"
const public_anon_key = "MY_ANON_KEY"
const supabase = createClient(supabaseUrl,public_anon_key)

exports.supabase = supabase

app.js

const { supabase }  = require('./client')

async function signOut() {
        /* sign the user out */
        await supabase.auth.signOut();
}

async function signInWithGithub() {
        /* authenticate with GitHub */
        await supabase.auth.signIn({
                provider: 'github'
        });
}

async function printUser() {
        const user = supabase.auth.user()
        console.log(user.email)
}

signInWithGithub()
printUser()
signOut()

I am new to Node.js and I suspect something wrong with Promises is missing. Is it possible to retrieve the user data from Supabase, if so, what is my code missing?

Thanks

Edit : title

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I don't know what Supabase does but the problem seems to be Promise related

Try to change your app.js as follow

const { supabase }  = require('./client')

function signOut() {
        /* sign the user out */
        supabase.auth.signOut();
}

function signInWithGithub() {
        /* authenticate with GitHub */
        return  supabase.auth.signIn({
                provider: 'github'
        });
}
function printUser() {
        const user = supabase.auth.user()
        console.log(user.email)
}

signInWithGithub().then(() => {
   printUser()
   return signOut()

})

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