public NexusDownloader() { TriggerLogin = ReactiveCommand.CreateFromTask( execute: () => Utils.CatchAndLog(NexusApiClient.RequestAndCacheAPIKey), canExecute: IsLoggedIn.Select(b => !b).ObserveOnGuiThread()); ClearLogin = ReactiveCommand.CreateFromTask( execute: () => Utils.CatchAndLog(async() => await Utils.DeleteEncryptedJson("nexusapikey")), canExecute: IsLoggedIn.ObserveOnGuiThread()); }
public NexusDownloader() { if (CLIArguments.ApiKey != null) { CLIArguments.ApiKey.ToEcryptedJson("nexusapikey"); } TriggerLogin = ReactiveCommand.CreateFromTask( execute: () => Utils.CatchAndLog(NexusApiClient.RequestAndCacheAPIKey), canExecute: IsLoggedIn.Select(b => !b).ObserveOnGuiThread()); ClearLogin = ReactiveCommand.Create( execute: () => Utils.CatchAndLog(() => Utils.DeleteEncryptedJson("nexusapikey")), canExecute: IsLoggedIn.ObserveOnGuiThread()); }
public AbstractIPS4OAuthDownloader(string clientID, Uri authEndpoint, Uri tokenEndpoint, IEnumerable <string> scopes, string encryptedKeyName) { ClientID = clientID; AuthorizationEndpoint = authEndpoint; TokenEndpoint = tokenEndpoint; EncryptedKeyName = encryptedKeyName; Scopes = scopes; TriggerLogin = ReactiveCommand.CreateFromTask( execute: () => Utils.CatchAndLog(async() => await Utils.Log(new RequestOAuthLogin(ClientID, authEndpoint, tokenEndpoint, SiteName, scopes, EncryptedKeyName)).Task), canExecute: IsLoggedIn.Select(b => !b).ObserveOnGuiThread()); ClearLogin = ReactiveCommand.CreateFromTask( execute: () => Utils.CatchAndLog(async() => await Utils.DeleteEncryptedJson(EncryptedKeyName)), canExecute: IsLoggedIn.ObserveOnGuiThread()); }
/// <summary> /// Sets up all the login facilites needed for a INeedsLogin downloader based on having the user log /// in via a browser /// </summary> /// <param name="loginUri">The URI to preset for logging in</param> /// <param name="encryptedKeyName">The name of the encrypted JSON key in which to store cookies</param> /// <param name="cookieDomain">The cookie domain to scan</param> /// <param name="cookieName">The cookie name to wait for</param> public AbstractNeedsLoginDownloader(Uri loginUri, string encryptedKeyName, string cookieDomain, string cookieName) { _loginUri = loginUri; _encryptedKeyName = encryptedKeyName; _cookieDomain = cookieDomain; _cookieName = cookieName; TriggerLogin = ReactiveCommand.CreateFromTask( execute: () => Utils.CatchAndLog(async() => await Utils.Log(new RequestSiteLogin(this)).Task), canExecute: IsLoggedIn.Select(b => !b).ObserveOnGuiThread()); ClearLogin = ReactiveCommand.Create( execute: () => Utils.CatchAndLog(() => Utils.DeleteEncryptedJson(_encryptedKeyName)), canExecute: IsLoggedIn.ObserveOnGuiThread()); }