First Android Game - Part 23 - Firebase APIs Jan 07, 2024
This is part 23 of making my first Android Game. If you missed part22, you can find it here. NOTE: I am using firebase SDK v 11.6.0. Before we continue adding more data. I want to know if I can manually create emails, verify emails and so forth using APIs. I am following this Firebase Auth Rest API First I can create a new email and password user by issuing an HTTP POST request to the Auth signupNewUser endpoint. This will allow the email to be registered and appear in Firebase Authentication. The endpoint is https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=[API_KEY] The sample request looks like the below The API_KEY which refers to the Web API Key, which can be obtained on the project settings page in your admin console. I replaced the API key,email and password. I would a get a response. Containing idtoken, email, refresh token,expires in and local id. Firebase Authentication would show the email I just created The id token is the Firebase id token of this user. I can use this token to send a verification email. The endpoint for verification email is https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=[API_KEY] The sample request is as shown below I placed the sample code in a txt file and give the file name with a json extension. This is the response I would see the email verification. Notice in the email there is oobCode key in the email link. I can use this oob to manually verify the email - we won't get to that yet as I want to do more testings before the email is verified. Will do it after I try signing in. It's great I can send email verification after I sign up a user. What if I already signed up and want to get the id token? I can SIGN IN instead! The end point for that is https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API_KEY] The sample request is shown below The response I get after I run the response is as shown below. Side note - I'm using a different email that's why the email in the image is different Using the id token I run the send verification email api discussed earlier. I can then manually confirm the verification email if I get the oobCode as discussed earlier which can be found in the verification email. The endpoint for confirming verification endpoint is https://identitytoolkit.googleapis.com/v1/accounts:update?key=[API_KEY] The response I get is as shown below I can also check if a user has verified their email. This is part of retrieving user's information. The endpoint for that is https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=[API_KEY] The sample request is as shown below As you can see, the response I get for a user that has verified their email, the emailVerified is set to true See next blog here
Recent blogs See all blogs