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

118
Visualizações
firebase functions calls to GCP - with a 403 - IAM blocks the call

Hello in this awesome 2022, that WILL be better!

here's the case we got and the problem we are facing:

  1. We have two parts of the same project - firebase (firebase functions created in javascript - project A) as well as google cloud (cloud function created in python - project B).
  2. From the FirebaseFunction part (A) we are sending a POST into the CloudFunction (B)
  3. We want this request to be authenticated with the IAM on GCP side (B)

And so in project A:

  const firebase = require("firebase-admin"); 
  const botInformURL = "URLTOHIT";
  const token = await firebase.auth().createCustomToken("XXX-notification-system"); 
  const output = await axios.post(botInformURL, {
      headers: {
        "Content-Type": "application/json",
        Authorization: "Bearer " + token,
      },
      method: "post",
      body: JSON.stringify({ additionalMessage }),

From the google cloud Platform (for CloudFunctions - in project B setup) I have added service account email ((...)projectA(...)iam.gserviceaccount.com) as a Cloud Functions Invoker (tried admin as well - without success)

And now - I am being blocked on the GCP with a 403.

What I am missing here?

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

0

When an unauthenticated caller sends a request to the Cloud Function, they will see a 401/403 status code response. In this scenario, the way out is to ensure that ‘allUsers’ has ‘roles/cloudfunctions.invoker’ role in the Cloud Function's IAM. You may refer to this documentation for more on this.

But yes, you are correct, if you use ‘allUsers’ it would expose the endpoint publicly and anyone would be able to access it.

If you want to avoid this, you have to follow the below steps:

From the receiving function:

 1. You need to configure the receiving function to accept requests from
    the calling function.  
 2. Use the gcloud functions add-iam-policy-binding command.

From the calling function:

 1. Create a Google-signed OAuth ID token with the audience (aud) set to
    the URL of the receiving function.
 2. Include the ID token in an
    Authorization: Bearer ID_TOKEN header in the request to the
    function.

You may also refer to the Stackoverflow link for more information.

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