title: Google Authentication In Xamarin Forms
body: <p>I am trying to authenticate a user in a Xamarin Forms app. I believe it has to be done differently for each platform, so I am using a function in MainActivity to authenticate when the app starts. I used the Google .NET documentation on their site but I am getting some errors.</p>
  
  <p>I've directly copied the Google code and I get the credentials.json through an embedded resource. The problem occurs when I try to setup the credential with GoogleWebAuthorizationBroker.AuthorizeAsync. In the google code, the credPath is set to token.json. I get an error that I don't have permission for this. I then tried to use Android.OS.Environment.ExternalStorageDirectory and I now get multiple errors. I cannot see the individual errors, only System.AggregateException: One or more errors occurred.</p>
  
  <pre><code>UserCredential credential;
  var assembly = typeof(MainActivity).GetTypeInfo().Assembly;
  using (var stream = 
  assembly.GetManifestResourceStream("Briefing.Droid.credentials.json"))
  {
     // The file token.json stores the user's access and refresh tokens, and is created
     // automatically when the authorization flow completes for the first time.
     string credPath = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "token.json");
     credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
     GoogleClientSecrets.Load(stream).Secrets,
     Scopes,
      "user",
      CancellationToken.None,
      new FileDataStore(credPath, true)).Result;
      Console.WriteLine("Credential file saved to: " + credPath);
   }
  </code></pre>
  
  <p>I expected a window to open that allowed the user to login with their google account. I get System.AggregateException: One or more errors occurred.</p>