Пример #1
0
        private static async Task SetApiKey()
        {
            var registerKeyMessage = "Next, you'll need to go to GitHub and register a personal access token. It only needs public_repo access. Copy the token to the clipboard.";

            MessageBox.Show(registerKeyMessage, "API Review List", MessageBoxButton.OK, MessageBoxImage.Information);

            var url = "https://github.com/settings/tokens/new";

            Shell.Execute(url);

            while (true)
            {
                var valiateTokenMessage = "Once the token is in the clipboard, click OK.";
                MessageBox.Show(valiateTokenMessage, "API Review List", MessageBoxButton.OK, MessageBoxImage.Information);

                var key = Clipboard.GetText();
                if (await GitHubClientFactory.IsValidKeyAsync(key))
                {
                    ApiKeyStore.SetApiKey(key);
                    break;
                }

                var keyIsInvalid = "The key in the clipboard is not valid.";
                MessageBox.Show(keyIsInvalid, "API Review List", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }