I have free version and paid version on play store both have firebase authentication how to make sure not login for other email accounts except the account purchased
Asked
Active
Viewed 199 times
1

Frank van Puffelen
- 565,676
- 79
- 828
- 807

Rajesh Wolf
- 1,005
- 8
- 12
-
They can login but you can stop them for accesing database. – Abubakker Moallim Dec 22 '17 at 11:42
-
how to get the purchased email account – Rajesh Wolf Dec 22 '17 at 11:43
-
create a seperate list of users who are not paid – Abubakker Moallim Dec 22 '17 at 11:44
-
https://stackoverflow.com/questions/37908795/how-do-you-block-users-on-firebase – Abubakker Moallim Dec 22 '17 at 11:45
-
my doubt is if you are purchasing the paid app on play store with abc@gmail.com how to get the email abc@gmail.com – Rajesh Wolf Dec 22 '17 at 11:46
-
You have implemented In-App purchase ? – Abubakker Moallim Dec 22 '17 at 11:46
-
no both are separate apps on play store – Rajesh Wolf Dec 22 '17 at 11:47
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/161806/discussion-between-rajesh-vinew-and-abdevelopers). – Rajesh Wolf Dec 22 '17 at 11:51
-
https://stackoverflow.com/questions/24863113/android-get-google-play-account-associated-with-in-app-billing *******answer is here **** – Rajesh Wolf Dec 22 '17 at 12:01
1 Answers
2
Consider using custom user claims and then enforcing access via Firebase rules or checking the presence of the custom claims in the ID token if you are parsing it in your own server: https://firebase.google.com/docs/auth/admin/custom-claims
After a user signs in and completes their purchase, you can send the purchase credentials to your backend to process it along with the user's ID token. If both are verified, you set the custom claim for that user:
admin.auth().setCustomUserClaims(uid, {paidSubscriber: true}).then(() => {...
You then force the client to refresh their token to get the latest claims:
currentUser.getIDToken(true)...
Now every request can check the user is authorized or not by checking the ID token.
{
"rules": {
"paidContent": {
".read": "auth.token.paidSubscriber === true",
".write": "auth.token.paidSubscriber === true",
}
}
}

bojeil
- 29,642
- 4
- 69
- 76