public static IObservable <UserCredential> AuthorizeTestGoogle(this XafApplication application, bool aquireToken = true) { if (aquireToken) { application.ObjectSpaceProvider.NewAuthentication(); } return(aquireToken ? application.AuthorizeGoogle() : application.GoogleNeedsAuthentication() .Select(b => b ? Observable.Throw <UserCredential>(new Exception(nameof(AuthorizeTestGoogle))) : application.AuthorizeGoogle()).Merge()); }
public static async Task <global::Google.Apis.Calendar.v3.CalendarService> CalendarService(this XafApplication application, bool deleteAll = false) { application.ObjectSpaceProvider.NewAuthentication(); var calendarService = await application.AuthorizeGoogle().NewService <global::Google.Apis.Calendar.v3.CalendarService>(); if (deleteAll) { var calendar = await calendarService.GetCalendar(CalendarName); await calendarService.DeleteAllEvents(calendar.Id); } return(calendarService); }