Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Can't receive messages from pubsub subscription with Enabled authentication

I have firebase http cloud function. I removed the permission Principal "all users" in it and added the service account project-id@appspot.gserviceaccount.com

Then I created a subscription, in which I specified the url of the function as a target (https://us-central1-project-id.cloudfunctions.net/pubsubPsaWorker/push), and also enabled authentication.
In the account field, I selected project-id@appspot.gserviceaccount.com
in the audience field, I also indicated https://us-central1-project-id.cloudfunctions.net/pubsubPsaWorker/push.

I made sure that the subscription sends requests with req.headers. authorization with a real token.

But when the subscription sends requests, I do not see any data in the function logs (which means that IAM does not miss requests from the subscription)

Also I tried doing curl -m 550 -X POST https://us-central1-project-id.cloudfunctions.net/pubsubPsaWorker\
-H "Authorization: bearer $(gcloud auth print-identity-token)" \
-H "Content-Type: application/json" \
-d '{}'
And in this case, I got a successful response and saw the logs.
Who knows what could be the problem?

The service account has the cloudFunction Invoker role.

alexDimov_0-1690979811758.png

alexDimov_1-1690980637529.png

 

 

0 1 439
1 REPLY 1

Hello @alexDimov ,

Sorry for the late revert.

As per guillaume, from a previous post in Stackoverflow, it might be the audience string. Using the same string as the end-point which is a longer path than the trigger defined on the function.