This tutorial is for those , who are looking to use firebase custom claims, using Android as a platform. Before using the claims , one must keep in mind that these claims should only be used for passing the very necessary details and should not be used for storing useless info like address.
Steps included are:
-
First of all install firebase CLI in your system , and use the command firebase init functions . For installation you can use the following link
-
Select typescript for firbase functions(in the functions folder ovveride the content of package.json file with the one given in this file)
3.Copy pase the index.ts file from this gist and deploy the function.
4.Now comes the android part now add a fucntion called addRole for that use the addClaim.java file from this gist,and then invoke the addRole() method (use the file callMethod.java for this)
5.Finally check the role , when the user login. (use the file getClaim.java),in this file in line 15 you get the role value, and you can use it accordingly.