I have a React + GraphQL application that reaches out to a Google Cloud Function to run some code. Currently I am allowing unauthenticated access, but I wish to lock it down. I am not seeing how I can authenticate like this in my React application:
fetch("https://REGION-PROJECT_ID.cloudfunctions.net/FUNCTION_NAME", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': access_token // <-------- this is what I want
},
body: JSON.stringify(something)
})
This example was stated in this thread: https://github.com/googleapis/google-auth-library-nodejs/issues/775
I would love to authenticate with a service account, but I don't want to have to use a Node server. Am I forced to go down the API key route?
This is the documentation for authenticating cloud functions:
https://cloud.google.com/functions/docs/securing/authenticating
Thanks!