I have 2 cloud run services:
- https://calculator-api.a.run.app (Ingress: Allow all traffic, Authentication: allUsers)
- https://add-api.a.run.app (Ingress: internal, Authentication: CloudIAM)
The idea is that calculator-api is public and it's going to make requests to add-api. For some reason, I am getting a 403 when the add-api ingress is internal but if I change the ingress to to Allow all traffic, it works perfectly.
I am getting the IdToken correctly using the following code and then I just inject the token in the header Authorization: Bearer IdToken. My receiver add-api has permission of calculator-api with Cloud Run Invoker role.
GET request "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?audience=https://add-api.a.run.app"
Header: {"Metadata-Flavor", "Google"}
So, I believe the problem is not the authentication but some kind of network limitation when the ingress is set to internal.