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

187
Visualizações
Firebase Pubsub Schedule Job can't run result is: "UNAUTHENTICATED"

I'm trying to realise a leaderboard for my App which should rewrite every 24h, but I can't get it to work... The job doesn't even start.

This is all I found about the function, but it doesn't help me. https://firebase.google.com/docs/functions/schedule-functions

And this is my function:

exports.leaderboardjob = functions.region('europe-west1').pubsub.schedule( '0 0 * * *').onRun(async (context) => {
    await leaderboard();
    console.log("job done");
    return null;
});

async function leaderboard(){

    const rdb = admin.firestore();

    const ref = rdb.ref('users');

    try {
        await ref.orderByChild('xp').limitToLast(2).on('child_added', (snapshot) => { //test first with 2 results
            console.log(snapshot.key);
        });

    } catch (error) {
         console.log('error: ' + error.message);
    }

    return{
        result: ok
    }
}

I already moved the function to my region europe-west1 like all my other functions.

error that I get back when I call this function (leaderboardjob) manually:

{"@type":"type.googleapis.com/google.cloud.scheduler.logging.AttemptFinished", "jobName":"projects/censored/locations/europe-west1/jobs/firebase-schedule-leaderboardjob-europe-west1", "pubsubTopic":"projects/censored/topics/firebase-schedule-leaderboardjob-europe-west1", "status":"UNAUTHENTICATED", "targetType":"PUB_SUB"}

Maybe its just not possible, if not: can someone explain me how to realise something like this with functions?

EDIT: I forgot to tell, that I gave the function the role with a new account "pubsub.subscriber"

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

0

I just deleted the whole function and tested it with a new name.

I don't know why, but this worked...

You don't even need to add a role. Everything works just fine.

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