public void Authorize() { string redirectUrl = _endpoint.GetAuthorizationUrl(OAuth2ResponseType.Pin); Process.Start(redirectUrl); _success.Show(strings.plsPin, TimeSpan.FromSeconds(2)); }
public async Task <bool> Login(string pin) { try { IOAuth2Token token = await _endpoint.GetTokenByPinAsync(pin); _client.SetOAuth2Token(token); FileIO.WriteRefreshToken(token.RefreshToken); User = token.AccountUsername; success.Show("Successfully logged in! Hi, " + User + "!", TimeSpan.FromSeconds(2)); return(true); } catch (Exception ex) { error.Show("Wrong PIN? Could not login to Imgur! (" + ex.Message + ")", TimeSpan.FromSeconds(2)); return(false); } }
private void DownloadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { string file = Path.Combine(_path, "ImgurSniperSetup.zip"); string extractTo = Path.Combine(_path, "ImgurSniperInstaller"); if (!File.Exists(file)) { _error.Show("Could not download ZIP Archive from github.com!", TimeSpan.FromSeconds(5)); Process.Start("https://mrousavy.github.io/ImgurSniper"); } else { Extract(file, extractTo); Process.Start(Path.Combine(extractTo, "ImgurSniperSetup.msi")); Application.Current.Shutdown(); } }
public async Task <bool> Login(string pin) { try { IOAuth2Token token = await _endpoint.GetTokenByPinAsync(pin); _client.SetOAuth2Token(token); ConfigHelper.WriteRefreshToken(token.RefreshToken); User = token.AccountUsername; UserUrl = $"http://{User}.imgur.com/all/"; _success.Show(string.Format(strings.loggedIn, User), TimeSpan.FromSeconds(2)); return(true); } catch (Exception ex) { _error.Show(string.Format(strings.wrongPin, ex.Message), TimeSpan.FromSeconds(2)); return(false); } }