I created a MAUI application on Windows which uses Google Calendar API to get events. I used the Google.Apis.Auth and Google.Apis.Calendar.v3 nuget packages.
This is the code which starts a browser to use the Google consent screen:
// Authenticate.
UserCredential credential;
using (Stream stream = await GetSecretStream())
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.FromStream(stream).Secrets,
new[] { CalendarService.Scope.CalendarReadonly },
"user", CancellationToken.None);
}
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "<AppName>",
});
...
// Get events.
var events = service.Events.List(calendar.Id).ExecuteAsync();
Unfortunately this code does not work on Android. I got an exception which says:
Failed to launch browser with https://accounts.google.com/o/oauth2/v2/auth?
access_type=offline ... for authorization; platform not supported.
How should I implement in Android?