xamarin / Xamarin.Auth

Xamarin.Auth
Apache License 2.0
541 stars 351 forks source link

Google 500 Error #296

Closed Jamesmallon1 closed 6 years ago

Jamesmallon1 commented 6 years ago

Xamarin.Auth Issue

"Google

  1. That's an error.

There was an error. Please try again later. That's all we know."

This is the screen that comes up now on my iPhone. This app has been working perfectly for the last 6 months and all of a sudden over the last 3 days this is all it produces.

This is specifically with Google sign in. Facebook and linkedin are working fine.

Version

Steps to reproduce

protected void ButtonGoogle_Clicked(object sender, EventArgs e)
        {
            provider = "Google";
            authenticator
                 = new Xamarin.Auth.OAuth2Authenticator
                 (
                     clientId:
                         new Func<string>
                            (
                                () =>
                                {
                                    string retval_client_id = "oops something is wrong!";

                                    // some people are sending the same AppID for google and other providers
                                    // not sure, but google (and others) might check AppID for Native/Installed apps
                                    // Android and iOS against UserAgent in request from 
                                    // CustomTabs and SFSafariViewContorller
                                    // TODO: send deliberately wrong AppID and note behaviour for the future
                                    // fitbit does not care - server side setup is quite liberal
                                    switch (Xamarin.Forms.Device.RuntimePlatform)
                                    {
                                        case "Android":
                                            retval_client_id = "xxxxxx";
                                            break;
                                        case "iOS":
                               retval_client_id = "xxxxxxx";
                                            break;
                                        case "Windows":
                                            retval_client_id = "xxxxxxxxx";
                                            break;
                                    }
                                    return retval_client_id;
                                }
                           ).Invoke(),
                    clientSecret: null,
                    authorizeUrl: new Uri("https://accounts.google.com/o/oauth2/auth"), 
                    accessTokenUrl: new Uri("https://accounts.google.com/o/oauth2/token"),
                    redirectUrl:
                        new Func<Uri>
                            (
                                () =>
                                {

                                    string uri = null;

                                    // some people are sending the same AppID for google and other providers
                                    // not sure, but google (and others) might check AppID for Native/Installed apps
                                    // Android and iOS against UserAgent in request from 
                                    // CustomTabs and SFSafariViewContorller
                                    // TODO: send deliberately wrong AppID and note behaviour for the future
                                    // fitbit does not care - server side setup is quite liberal
                                    switch (Xamarin.Forms.Device.RuntimePlatform)
                                    {
                                        case "Android":
                                            uri =
                                                "com.xxxxxx:/oauth2redirect";
                                            break;
                                        case "iOS":
                                            uri =
                                                "com.xxxxx:xamarin-auth";
                                            break;
                                        case "Windows":
                                            uri =
                                                "com.xamarin.auth.windows:/oauth2redirect";
                                            break;
                                    }

                                    return new Uri(uri);
                                }
                             ).Invoke(),
                      scope: "email",
                     getUsernameAsync: null,
                     isUsingNativeUI: true
                 )
                 {
                     AllowCancel = true,
                 };

            authenticator.Completed += OnAuthCompleted;

            authenticator.Error += OnAuthError;

            // after initialization (creation and event subscribing) exposing local object 
            AuthenticationState.Authenticator = authenticator;

            PresentUILoginScreen(authenticator);

            return;
        }

Platform:

Expected behaviour

It should give me an option to log into my google account

Actual behaviour

As said above on the actual behaviour.

Amenti commented 6 years ago

We encounter the same error but restricted to Android on real devices, the emulator runs fine though.

Jamesmallon1 commented 6 years ago

It’s really really strange. When I press the safari button in the in app browser it takes me to the login page and then I can return to the app and it logs me in. But the error seems to specifically be with the SFSafari View controller or in app browser. Any fixes available?

moljac commented 6 years ago
  1. That's an error. There was an error. Please try again later. That's all we know."

This means server side error. Please checvk logs on server side.

This app has been working perfectly for the last 6 months and all of a sudden over the last 3 days this is all it produces.

OAuth service providers like google constantly change OAuth implementation, so something might have changed.

Did you change nuget versions in your app?

This is specifically with Google sign in. Facebook and linkedin are working fine.

This is proof that most likely Xamarin.Auth is not the issue here.

Please close this issue if it is not possible to provide more info or answer is satisfying.

Jamesmallon1 commented 6 years ago

@moljac

Thank you for taking the time to reply. I don't believe the there is any proof that Xamarin Auth is not the issue. The actual issue is that due to the fact that Google Sign in requires native UI. On loading said native UI the error occurs. LinkedIn and Facebook both use separate web views. However using just the safari app on the iPhone the issue does not occur.

I have not changed nuget versions of the app and I have checked everything on Google's side and everything seems to be completely fine.

Jamesmallon1 commented 6 years ago

I'm really starting to get desperate here. There is absolutely no information on this error or how to fix it. I've tried different API Keys and on different accounts, different phones etc etc but to no success. Has anyone come accross this issue and managed to fix it?

moljac commented 6 years ago

@Jamesmallon1

Can you provide me a minimal repro sample, pleas? In some private repo, or in priave chat in Xamarin community slack team...

Amenti commented 6 years ago

In our case it seems to work again. We did not publish any updates in this time frame so I think Google was the culprit here.

Jamesmallon1 commented 6 years ago

@Amenti

I believe you are correct all fixed now. Extremely strange that the outages lasted about a period of 2-3 weeks! apologies.