private async Task <bool> IsApiTokenCorrect(string token)
        {
            using (var client = new FhClient(token))
            {
                try
                {
                    await client.GetFeed();
                }
                catch (FhRequestException exception)
                {
                    if (exception.Error.Status == 401)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Settings.Default.ApiToken))
            {
                var settingsForm = new SettingsForm();
                var dialogResult = settingsForm.ShowDialog();

                if (dialogResult != DialogResult.OK)
                {
                    Environment.Exit(Environment.ExitCode);
                    return;
                }
            }

            fhCient = new FhClient(Settings.Default.ApiToken);

            FeedUpdateTimer.Interval = Settings.Default.SecondsBeforeUpdateFeed * 1000;
            FeedUpdateTimer.Start();
            FeedUpdateTimer_Tick(this, null);
        }