1

I need to authenticate the user using typescript in cloud function, Where i will be sending the users data (i.e email and password) as request body to the function, In function i need to authenticate the user using firebase and based on response i will be sending to the user.
Example

export const authenticate= functions.https.onRequest(async (request, response) => {

   //I need to authenticate the user with email and password to get 
    the UID of the user, but i don't know how to authenticate the 
    user using firebase
    response.send("{
     UID : "FIREBASE UID"
  }");

}).catch(error => {
console.log(error)
    response.send("{
     error :SIGNIN FAILED
}");
});

Can anyone help me out with this ?

Stack
  • 1,164
  • 1
  • 13
  • 26
  • Is this answers your questions? https://stackoverflow.com/questions/42751074/how-to-protect-firebase-cloud-function-http-endpoint-to-allow-only-firebase-auth – Yosi Pramajaya Jul 13 '19 at 08:07
  • What do you want to achieve? Do you want to authenticate the user on client side or on the server side? – Sebastian Vischer Jul 13 '19 at 10:53
  • 1
    Firebase Auth is optimized for client side rendering. Also your function looks really insecure. You are returning a plain `uid` to the client. This is equivalent to no security. Firebase Auth generates an ID token after a user authenticates. This is the right mechanism to determine if a user is authenticated. – bojeil Jul 15 '19 at 05:09

0 Answers0