I am trying to call a HTTP triggered Cloud Function from a node server running on an instance of Compute Engine. I have set the Compute Engine's service account as invoker of the said function and both the function as the compute engine instance are operating on the same VPC network. Yet, I am getting the default 403 Forbidden error every time I try to call the function from my node server. If I, however, set the rules of invocation in the Cloud Function to "allUsers" the call is made successfully.
Edit: I am running the node server on a docker container.
Any ideas on what is happening?
Thanks a lot in advance.
Edit (solution):
So the solution that I was looking for is explained here. Even though the sample code for which the above link points to might help someone, I found it more useful to follow this guide (Service Account JSON certificate) which points to code one can use to get the OIDC token necessary to provide in the request to the function (just remember that the audience when creating the token must be set to the function's url).
Having the aforementioned OIDC token, one can call the cloud function using a normal HTTP request simply by passing the header Authorization in the following format: Authorization: Bearer {OIDC token}.
Feel free to post any questions regarding this, I will try to answer all. Thanks again to petomalina for pointing in the right direction.
[PROJECT_NUMBER][email protected]
. Can you please check if your compute instance isn't using this service account instead of the developer one? You may need to add the invoker role to this service account. – petomalina