Use Auth0 with Excel addin

Hello, i am building an Excel add in (local with Visual Studio in C#). In that add in i have a loginform. I am new to Auth0 and also just starting with C#. I can’t get a connection with Auth0, if I push the button in Excel on the loginform I got an error: De aanvraag is afgebroken: Kan geen beveiligd SSL/TLS-kanaal maken." (Could not establish secure channel for SSL/TLS with authority). Can please anyone help me? I use the following code:
public partial class LoginForm : Form
{
private AuthenticationApiClient client;
public LoginForm()
{
InitializeComponent();

        client = new AuthenticationApiClient(
        new Uri("https://{domain}.auth0.com" )
        );


    }
    private async void btnLogin_Click(object sender, EventArgs e)
    {
        
        var request = new ResourceOwnerTokenRequest
        {
            ClientId = "{myclientid}",
            ClientSecret = "{myclientsecret}",
            Scope = "openid profile email",
            Realm = "Username-Password-Authentication", // Use the appropriate connection name
            Username = txtUsername.Text,
            Password = txtPassword.Text
        };
        
        //try
        {
            var response = await client.GetTokenAsync(request);


            if (response != null && !string.IsNullOrEmpty(response.AccessToken))
            {
                MessageBox.Show("Login successful!");
                // Proceed with your application after successful authentication
            }
            else
            {
                MessageBox.Show("Login failed.");
            }
        }
        //catch (Exception ex)
        //{
        //    MessageBox.Show($"Login error: {ex.Message}");
        //}
    }

…other code.

I really appreciate if anyone can help me.

solved it by adding
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.