I am using Firebase with my React Native app, and I only have anonymous login enabled.
I am trying to call a Cloud Function from the app, but not using the firebase SDK. Instead I want to call it with axios. When I pass the token grabbed from my firebase user as a Bearer token, I get back a 401 Unauthorized.
However, the request goes through if I copy the token I get from the CLI with gcloud auth print-identity-token.
How can I grab/setup a valid token that I could pass to the Cloud Function? Any relevant doc would be appreciated.
Im trying to call the function using a onRequest:
await axios.post(CLOUD_FUNC_URL, payload, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
I am either grabbing the token from gcloud CLI (works) but the one from await auth().currentUser?.getIdToken(); does not.