0

I am just getting started with Firebase Functions. I have tested successfully using the emulator suite and see my function working well. However, when deploying my function and trying to access the generated URL for my function, I get a 403 Forbidden error.

I checked Google Cloud IAM console and see that my current account is set as the Owner role for the function, but I also added the "Cloud Functions Admin" role as well.

Despite these permissions, I am still seeing the 403 Forbidden errors when trying to access my function.

I do not wish to make my function public, though I did perform a test with public access enabled and I was able to access my function and it ran successfully. I revoked the public access after this test, though, and would prefer to keep the function private. Most answers I see to this question simply say to open the function up for public access by setting the "allUsers" member to have the "invoke cloud functions" role.

I am not sure what else to try. Any help would be appreciated!

h_k
  • 1,674
  • 1
  • 24
  • 46

1 Answers1

0

You can't access directly the Cloud/Firebase Function that requires authentication if it doesn't have a login authentication or verifying identity of the users inside your function, it means you need to build/codes a function for it.

You can test your Cloud Function using curl via CLI but you will use the gcloud auth print-identity-token for authentication, example:

curl https://REGION-PROJECT_ID.cloudfunctions.net/FUNCTION_NAME \
  -H "Authorization: bearer $(gcloud auth print-identity-token)"

To access your Cloud/Firebase Function you can integrate Google Sign-In with Firebase Authentication and there are a lot of example and explanation in Stack Overflow how you can access your Cloud/Firebase Function that requires an authentication, it will depend on your case:

  1. Callable Function
  2. Generate Token(google-auth-library)
  3. from `firebase-admin
  4. Another example of Cloud Function with Firebase Authentication
  5. Limit access to your Cloud Function Answer/Explanation
  6. Background Information
JM Gelilio
  • 3,482
  • 1
  • 11
  • 23