Example #1
0
        private void newAccessTokenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ClientInformation newClientInfo;

            AccessTokenWizard accessTokenWizard = new AccessTokenWizard();

            if (accessTokenWizard.ShowDialog(out newClientInfo) == DialogResult.OK)
            {
                // Override current info.
                clientInfo = newClientInfo;

                if (clientInfo.AuthType == AuthEndpoints.Basic)
                {
                    // Basic auth

                    textBox_BasicAuthSMTPAddress.Enabled            = true;
                    textBox_BasicAuthSMTPAddress.Text               = "";
                    textBox_BasicAuthPassword.Enabled               = true;
                    textBox_BasicAuthPassword.Text                  = "";
                    textBox_BasicAuthPassword.UseSystemPasswordChar = true;
                }
                else if (clientInfo.AuthType == AuthEndpoints.OAuthV1)
                {
                    // OAuth V1

                    textBox_BasicAuthSMTPAddress.Enabled            = false;
                    textBox_BasicAuthSMTPAddress.Text               = "OAuth (V1 Endpoint)";
                    textBox_BasicAuthPassword.Enabled               = false;
                    textBox_BasicAuthPassword.Text                  = "OAuth (V1 Endpoint)";
                    textBox_BasicAuthPassword.UseSystemPasswordChar = false;
                }
                else
                {
                    // OAuth V2

                    textBox_BasicAuthSMTPAddress.Enabled            = false;
                    textBox_BasicAuthSMTPAddress.Text               = "OAuth (V2 Endpoint)";
                    textBox_BasicAuthPassword.Enabled               = false;
                    textBox_BasicAuthPassword.Text                  = "OAuth (V2 Endpoint)";
                    textBox_BasicAuthPassword.UseSystemPasswordChar = false;
                }

                button_ViewTokenInfo.Enabled = !string.IsNullOrEmpty(clientInfo.Token.access_token);
                button_RefreshToken.Enabled  = !string.IsNullOrEmpty(clientInfo.Token.refresh_token);
                button_Run.Enabled           = true;

                // Select the Body page.
                tabControl_Request.SelectTab(1);
            }
        }
        private void newAccessTokenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ClientInformation newClientInfo;

            AccessTokenWizard accessTokenWizard = new AccessTokenWizard();

            if (accessTokenWizard.ShowDialog(out newClientInfo) == DialogResult.OK)
            {
                // Override current info.
                clientInfo = newClientInfo;

                if (clientInfo.AuthType == AuthEndpoints.Basic)
                {
                    // Basic auth

                    useBasicAuth = true;
                    textBox_BasicAuthSMTPAddress.Enabled            = true;
                    textBox_BasicAuthSMTPAddress.Text               = "";
                    textBox_BasicAuthPassword.Enabled               = true;
                    textBox_BasicAuthPassword.Text                  = "";
                    textBox_BasicAuthPassword.UseSystemPasswordChar = true;
                }
                else if (clientInfo.AuthType == AuthEndpoints.OAuthV1)
                {
                    // OAuth V1

                    useBasicAuth = false;
                    textBox_BasicAuthSMTPAddress.Enabled            = false;
                    textBox_BasicAuthSMTPAddress.Text               = "OAuth (V1 Endpoint)";
                    textBox_BasicAuthPassword.Enabled               = false;
                    textBox_BasicAuthPassword.Text                  = "OAuth (V1 Endpoint)";
                    textBox_BasicAuthPassword.UseSystemPasswordChar = false;
                }
                else
                {
                    // OAuth V2

                    useBasicAuth = false;
                    textBox_BasicAuthSMTPAddress.Enabled            = false;
                    textBox_BasicAuthSMTPAddress.Text               = "OAuth (V2 Endpoint)";
                    textBox_BasicAuthPassword.Enabled               = false;
                    textBox_BasicAuthPassword.Text                  = "OAuth (V2 Endpoint)";
                    textBox_BasicAuthPassword.UseSystemPasswordChar = false;
                }



                _tokenResponse = clientInfo.Token;
                _resource      = clientInfo.ResourceUri;
                _clientID      = clientInfo.ClientID;
                _clientSecret  = clientInfo.ClientSecret;
                _scopes        = clientInfo.Scopes;
                _redirectUri   = clientInfo.RedirectUri;
                _useV2Endpoint = (clientInfo.AuthType == AuthEndpoints.OAuthV2);

                button_ViewTokenInfo.Enabled = !string.IsNullOrEmpty(clientInfo.Token.access_token);
                button_RefreshToken.Enabled  = !string.IsNullOrEmpty(clientInfo.Token.refresh_token);
                button_Run.Enabled           = true;

                // Select the Body page.
                tabControl_HeadersAndBody.SelectTab(1);
            }

            //AcquireAccessToken();
        }