XafApplication NewApplication(Platform platform, ModuleBase[] modules) { var xafApplication = platform.NewApplication <GoogleModule>(); xafApplication.Modules.AddRange(modules); return(xafApplication); }
protected GoogleModule GoogleModule(Platform platform = Platform.Win, params ModuleBase[] modules) { var application = NewApplication(platform, modules); application.SetupGoogleSecurity(); var module = application.AddModule <GoogleModule>(); application.Model.ConfigureGoogle(platform); application.Logon(); application.CreateObjectSpace(); return(module.Application.Modules.OfType <GoogleModule>().First()); }
public static void ConfigureGoogle(this IModelApplication application, Platform platform) { var json = JsonConvert.DeserializeObject <dynamic>( File.ReadAllText($"{AppDomain.CurrentDomain.ApplicationPath()}\\Google{platform}AppCredentials.json")); var modelOAuth = application.ToReactiveModule <IModelReactiveModuleOffice>().Office.Google().OAuth; modelOAuth.AddScopes("https://www.googleapis.com/auth/tasks", "https://www.googleapis.com/auth/calendar.events", "https://www.googleapis.com/auth/calendar"); if (platform == Platform.Win) { modelOAuth.ClientId = json?.installed.client_id; modelOAuth.ClientSecret = json?.installed.client_secret; } else { modelOAuth.ClientId = json?.web.client_id; modelOAuth.ClientSecret = json?.web.client_secret; modelOAuth.RedirectUri = json?.web.redirect_uris[0]; } }
public static void NewAuthentication(this IObjectSpaceProvider objectSpaceProvider, Platform platform = Platform.Win) { objectSpaceProvider.NewAuthentication <MSAuthentication>((authentication, bytes) => authentication.Token = bytes.GetString(), "Microsoft", platform); }
protected override void OnConnect_Action_Creates_Connection(Platform platform, XafApplication application) => GoogleService.CustomAcquireTokenInteractively .Do(args => NewAuthentication(platform, application)) .Do(e => e.Instance = Observable.Empty <UserCredential>().FirstOrDefaultAsync()).Test();
protected override void NewAuthentication(Platform platform, XafApplication application) => application.ObjectSpaceProvider.NewAuthentication(platform);
protected override XafApplication Application(Platform platform) => GoogleModule(platform).Application;
public static void NewAuthentication(this IObjectSpaceProvider objectSpaceProvider, Platform platform = Platform.Win) { objectSpaceProvider.NewAuthentication <GoogleAuthentication>((authentication, bytes) => { authentication.OAuthToken = (Dictionary <string, string>) new DictionaryValueConverter().ConvertFromStorageType(bytes.GetString()); }, "Google", platform); }
public static void NewMicrosoftAuthentication(this IObjectSpaceProvider objectSpaceProvider, Platform platform = Platform.Win) { using (var manifestResourceStream = File.OpenRead($"{AppDomain.CurrentDomain.ApplicationPath()}\\AuthenticationData{platform}.json")){ var token = Encoding.UTF8.GetBytes(new StreamReader(manifestResourceStream).ReadToEnd()); using (var objectSpace = objectSpaceProvider.CreateObjectSpace()){ var authenticationOid = (Guid)objectSpace.GetKeyValue(SecuritySystem.CurrentUser); if (objectSpace.GetObjectByKey <MSAuthentication>(authenticationOid) == null) { var authentication = objectSpace.CreateObject <MSAuthentication>(); authentication.Oid = authenticationOid; authentication.Token = token.GetString(); objectSpace.CommitChanges(); } } } }