I have seen similar questions however my use-case seems different. Let me explain.
- I have a SINGLE project.
- I am using Firebase Authentication in the project
- I have created a Node JS based http Cloud Function to different routes.
Using Postman I do a POST request to the Cloud function and use the login
route and pass the email and password and get the token in the response.
Using Postman I do a POST request to the Cloud function and use the check
route by passing the token from the earlier request and authenticate the token. It works. For this I use the admin.auth().verifyIdToken
function of the firebase admin client.
All seems well.
Now, when I set up a Google Cloud Endpoint (on a Google Cloud Run container) in the same project, and:
I have not setup any securities option (as yet) in the Firebase stagger yaml file.
I may a POST request to the Google Cloud Endpoint using
login
path, I receive the token as before.But when I make my POST request using the Endpoint to the
check
path, I receive the "Firebase ID token has incorrect "aud" (audience) claim." error.
I seemed to have tried every option offered by others in these forums. I have created a private key from the firebase console and initialised the firebase admin client with it and yet I get the same error which says: "The claim is supposed to the Project-Id but it takes it to be the Function-name" which is part of the same project.
I have setup my node js function with cors (app.use(cors())
) too but same error perpetuates.
I have been at it for the last 4-5 days but do not seem to find out what is the exact problem and why is it not able to accept the admin client function call. Anyone giving me a direction to pursue will be highly appreciated. Thanks.