CreateAuthenticateRequest() public method

public CreateAuthenticateRequest ( string username, string password ) : IRestRequest
username string
password string
return IRestRequest
示例#1
0
        private void pictureBox1_Click(object sender, System.EventArgs e)
        {
            var flag = false;

            try
            {
                var restRequestFactory    = new RestRequestFactory();
                var jiraApiRequestFactory = new JiraApiRequestFactory(restRequestFactory);

                var restClientFactory = new RestClientFactory {
                    BaseUrl = tbJiraBaseUrl.Text
                };

                var jiraApiRequester = new JiraApiRequester(restClientFactory, jiraApiRequestFactory, new HttpBasicAuthenticator(tbUsername.Text, tbApiPrivateToken.Text));
                var request          = jiraApiRequestFactory.CreateAuthenticateRequest();
                var response         = jiraApiRequester.DoAuthenticatedRequest <object>(request);
                var authObj          = response as Dictionary <string, object>;
                if (authObj != null && authObj.ContainsKey("avatarUrls"))
                {
                    var avartObj = authObj["avatarUrls"] as Dictionary <string, object>;
                    if (avartObj != null)
                    {
                        flag = true;
                        picBox.LoadAsync(avartObj["48x48"].ToString());
                    }
                }
            }
            catch (Exception)
            {
            }

            if (!flag)
            {
                var msg = $"Jira StopWatch could not connect to your Jira server. {Environment.NewLine}";
                MessageBox.Show(msg, "Failed to retrieve JIRA Avatar!");
            }
        }