Auth0 with Console Application

Hi, I have issues with Auth0 login with console application.

I got WebViewBrowserChromium from one of the post.

When I try to call this web view form in Main Program.cs, I alwasy got the error
Cannot change thread mode after it is set.

I think the issue is with WebViewForm2

Any idea? Thanks

Hi @wyang

Welcome to the Auth0 Community!

Can you share more details regarding your use case, which SDK you are using, and share the exact error?

Thanks!
Dawid

Basically, it will have error in

    var loginResult = await auth0Client.LoginAsync(extraParameters: extraParameters);

The error is
System.Runtime.InteropServices.COMException: ‘Cannot change thread mode after it is set. (Exception from HRESULT: 0x80010106 (RPC_E_CHANGED_MODE))’

I’m try to post a screenshot, but I cannot.

Always get the error:

An error occurred: Sorry, you can’t embed media items in a post.

I try to make it simple, Create a new .net Framework4.7.2 Windows Form Application.

Add the all the required reference.

Adding the code like this in Program.cs file. When you run it, you will see the error.

[STAThread]
static async Task Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

        var options = new Auth0ClientOptions
        {
            Domain = {Domain},
            ClientId = {Client Id},
            Scope = "openid profile refresh",
            RedirectUri = {RedirectUri},
            PostLogoutRedirectUri = {PostLogoutRedirectUri}

        };

        var auth0Client = new Auth0Client(options);

        var extraParameters = new Dictionary<string, string>
            {
                { "connection", "Username-Password-Authentication" },
                { "audience", {audience} }
            };
        var loginResult = await auth0Client.LoginAsync(extraParameters: extraParameters);

        if (loginResult.IsError)
        {
            //Log(loginResult.Error + "\r\n" + loginResult.ErrorDescription, "Login response");
            throw new Exception(loginResult.ErrorDescription);

        }


        Application.Run(new Form1());
    }