Closed
Description
Hi, I'm running GMail API in ASP.NET Core 2.0 on Ubuntu 16.04 and I can't get the OAuth to work.
My code looks like this:
UserCredential credential;
if (emails == null || emails.Length == 0)
return Task.CompletedTask;
using (var stream =
new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
string credPath = "gmail.json";
log.Info("Creating FileDataStore "+credPath);
var fds = new FileDataStore(credPath, true);
log.Info("Loading secrets");
var secrets = GoogleClientSecrets.Load(stream).Secrets;
log.Info("Running AuthorizeAsync");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
secrets,
Scopes,
"user",
CancellationToken.None,
fds).Result;
log.Info("Credential file saved to: " + credPath);
}
// Create Gmail API service.
var service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
It works from a windows machine, I get a nice OAuth flow. But on Ubuntu I see
Sep 28 11:17:43 vm dotnet-app[67214]: xdg-open: unexpected argument 'https:%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.compose'
Sep 28 11:17:43 vm dotnet-app[67214]: Try 'xdg-open --help' for more information.
in the output of dotnet and this in the log:
2017-09-28 11:17:42,860 INFO app.Services.EmailSender - Creating FileDataStore gmail.json
2017-09-28 11:17:42,860 INFO app.Services.EmailSender - Loading secrets
2017-09-28 11:17:43,016 INFO app.Services.EmailSender - Running AuthorizeAsync
and that never finishes, the app just times out there