question

ShantimohanElchuri-8757 avatar image
0 Votes"
ShantimohanElchuri-8757 asked ShantimohanElchuri-8757 commented

Google signin crashing on phone but works on simulator

My SignIn method is as follows:

 public void SignIn()
 {
     Debug.WriteLine("In SignIn");
     if (GdAuthenticator == null)
     {
         (App.GdClientId, App.GdRedirectUrl, App.GdClientSecret) = App.SetIDs4GoogleDrive();

         Debug.WriteLine($"GdRedirectUrl: {App.GdRedirectUrl}");
         GdAuthenticator = new OAuth2Authenticator(
             App.GdClientId,
             App.GdClientSecret,
             App.GdScope,
             new Uri("https://accounts.google.com/o/oauth2/v2/auth"),
             new Uri(App.GdRedirectUrl),
             new Uri("https://www.googleapis.com/oauth2/v4/token"),
             isUsingNativeUI: true);
         GdAuthenticator.Completed += Auth_Completed;

         AuthenticatorHelper.OAuth2Authenticator = GdAuthenticator;
     }

     // This flag is set here as for iOS, AppDelegate.OpenUrl is invoked even before
     //    this.Auth_Completed event is invoked and this flag is needed to redirect
     //    to this app after authentication
     if (Device.RuntimePlatform == Device.iOS)
         App.StorageServiceSignedIn = App.StorageServices.GoogleDrive;

     OAuthLoginPresenter presenter = new OAuthLoginPresenter();
     presenter.Login(GdAuthenticator);
 }

GdScope is set as follows:

 public static string GdScope = "https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file";


The error occuring is:

System.UnauthorizedAccessException
Message=Access to the path '/private/var/mobile/Containers/Data/Application/FE509305-6324-4705-B517-DA2A98B18A69/.local/share/google-filedatastore/Google.Apis.Auth' is denied.

I don't find any line containing "FE5" in the device logs.

The Publishing Status of my app on Google API site is "Testing".

Since it is not failing on the simulator I assume that all authentications are in order. The app is run on iPhone 6 in Debug mode.

I published the app to App Store after testing in Debug mode but never tested on device in Release mode. But I found the issue after users facing crash issue while signing into Google Drive services that I am using in the app.

Let me know if you need any further info.

ThanQ...






dotnet-xamarinformsdotnet-ios
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ShantimohanElchuri-8757 About this error, here I found a similar thread maybe you can refer to. How to implement Google Auth Login in Xamarin Forms?. Do the simulator and device have the same iOS version? Besides, about Google Auth in Xamarin, you can also try Xamarin.Essentials: Web Authenticator. Here is a related thread: Xamarin.Essentials: Web Authenticator.

0 Votes 0 ·

I don't think I can follow your first link of "How to implement Google Auth Login in Xamarin Forms?" as it is using GoogleWebAuthorizationBroker which I am not using. So I am not declaring any path to store. All those paths are set internally by the API. I have no control over them. Then how do I authorize those paths? Do I have to set any permission on the phone?

Regarding OS versions, yes they are vastly different. My phone is iPhone 6 running iOS 12.5.2 and the simulator is running iOS 14.5. But my users who reported issue were running iOS 14.5.



0 Votes 0 ·
KyleWang-MSFT avatar image KyleWang-MSFT ShantimohanElchuri-8757 ·

@ShantimohanElchuri-8757 About Google.Apis issue, maybe you can submit an issue on Github. And I noticed that I posted the wrong link for Web Authenticator in the previous comment and have changed it.

0 Votes 0 ·
Show more comments

0 Answers