Search code examples
ionic3google-oauthcordova-pluginsgoogle-signininappbrowser

Can not Authenticate Google users from an Ionic App, gets a "Couldn't sign you in" error


We have implemented an ionic application that uses Google Authentication to retrieve the Calendar details of the Google account.

For that what we do is, open a browser window from the Ionic application and direct the user to the authentication page.

For some Google accounts this working fine. But for some accounts, we get the below error.

I also tried allowing access for "Less secure apps".

I also observed that this works for some GSuite accounts and do not work for some GSuite accounts. This also happens for private accounts(Personal) as well.

Is there any suggestions or information regarding this issue?

[This error occurs just after we enter the email and proceed.]

Link to the snapshot


Solution

  • do you have a OverrideUserAgent preference in your config.xml? you might be using an outdated user agent. try replacing it with this for android:

     <preference name="OverrideUserAgent" value="Mozilla/5.0 (Linux; Android 10; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Mobile Safari/537.36" />
    

    or this for ios:

    <preference name="OverrideUserAgent" value="Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" />