Hi there,
I'm looking for the code snippet or some guidance for an alternative way to not use JSON keys with my service account to authenticate for my Google Cloud functions
I am using a service account already for my compute engine but for security reasons, I rather not use JSON key to authenticate
Thanks
Hello @Sheldon_Sab,
Take a look at this documentation: Authenticate for invocation.
With the appropriate permissions, you can generate tokens programmatically or manually. Try using the metadata server to fetch ID Tokens with the specific audience as follows:
curl "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?audience= AUDIENCE" \
-H "Metadata-Flavor: Google"
Replace AUDIENCE with the URL of the function you are invoking. You can retrieve this URL as described in the Authenticating developer testing section above.
Let me know if it helped, thanks!