Sammi3
Sammi3

Reputation: 397

Authentication flow with custom token for Firebase Authentication on cloud functions

I'm creating a game in which I would like to use firebase authentication using cloud functions for logging in and registering users. Since my dev platform (GameMaker Studio 2) doesn't have the firebase sdk, I've resulted in attempting to use the firebase auth restAPI. To authenticate a user, I have to at one point create a custom token using the users uID and then use that to login. The problem with this is that I can't really understand the flow of the authentication. How could the client have knowledge beforehand on it's userID from parameters such as email and password?

Any help in understanding the flow I need to authenticate a user will be greatly appreciated.

Upvotes: 0

Views: 605

Answers (1)

Ajay Raj Merchia
Ajay Raj Merchia

Reputation: 16

If you're developing on node.JS, you should be able to use npm to install the firebase package -- that would simplify things greatly.

Otherwise, the overall flow of authentication should look as follows.

  1. Client gives email and password
  2. Pass email & password to Firebase Authentication using your HTTP request. You should receive an auth token, and a uID if authentication was successful. (see here)
  3. Now you have an id token that you can set as a cookie in your client's browser. You can verify this cookie by storing it in your backend for each subsequent GET request to your Node server.

Upvotes: -1

Related Questions