russmedia-digital / cordova-plugin-google-signin

Cordova Google SignIn
Apache License 2.0
11 stars 29 forks source link

Android OneTap plugin with cooldown period #1

Closed pghoratiu closed 2 years ago

pghoratiu commented 2 years ago

When accessing the one tap functionality on Android if the user chooses not to authenticate we should not ask again on the second run of the app within a short period of time, let's say 24 h.

This is important because google will block all future auth requests if the user chooses not to authenticate via one tap the first time.

Stop displaying the One Tap UI If the user declined to sign in, the call to getSignInCredentialFromIntent() will throw an ApiException with a CommonStatusCodes.CANCELED status code. When this happens, you should temporarily disable the One Tap sign-in UI so you don't annoy your users with repeated prompts. The following example accomplishes this by setting a property on the Activity, which it uses to determine whether to offer the user One Tap sign-in; however, you could also save a value toSharedPreferences or use some other method. It's important to implement your own rate limiting of One Tap sign-in prompts. If you don't, and a user cancels several prompts in a row, the One Tap client will not prompt the user for the next 24 hours.

https://developers.google.com/identity/one-tap/android/get-saved-credentials#disable-one-tap

Within the app I get the following error message:

{"status" : "error", "message" : "16: Caller has been temporarily blocked due to too many canceled sign-in prompts."}

liyamahendra commented 2 years ago

@pghoratiu I developed this plugin and Gabriel requested me to look into this.

You're right - the plugin would return error message when the OneTap login has been denied by the user.

I think it ideal to handle the check you're referring within the app UI and save in LocalStorage / SharedPreferences if the OneTap is denied by the user. Based on the value, the UI for OneTap signin can be disabled.

Thoughts?

liyamahendra commented 2 years ago

@pghoratiu I created a Pull Request with the change implemented.

Let me know if that solves the requirement.

pghoratiu commented 2 years ago

Merged.