Problem with following the Auth0 "Quick Start" tutorial from my application homepage

Hello,

I am brand new to .NET and c sharp development. Me and few other computer science students are trying to build a web page, and so far we have a very simple web page without any authentication. We need to be able to allow certain users special privileges, while part of site will be public. I followed the tutorial on my Auth0 account for creating an app, and I tried to integrate that material into our simple web application. When I thought was done, I built the application successfully, but it crashed when I ran it, giving the following error message: “ArgumentException: Options.ClientId must be provided (Parameter ‘ClientId’)”.

Any ideas about what could be causing this? Should I post some snippets of my code?

Thanks!

Hi @skipjack,

welcome to the community.

A link to the tutorial you’re using would help. Also, are you passing a value for the Client.Id as stated in the error message?

Yes, a code snippet that makes the authorization call to Auth0 would also be helpful.

1 Like

I appreciate your reply!

I don’t think I’m passing Client.Id explicitly because they didn’t do so in the tutorial. However, after receiving the error I tried looking online for examples of how to pass that value and I tried a few things to no avail. I’m not certain if I placed the call in the correct place or if I passed the correct value… but since it didn’t seem to work I have since commented out or erased these attempts.

I feel like it will probably make it a lot easier for me to be helped if I post a bunch of code snippets, so I’ll post a snippet at the bottom of this message. But please ask me for anything you might want to look at. I just don’t want to flood this thread right away with a bunch of irrelevant code since I’m not super certain about which files/sections will or won’t be relevant for sure.

Here is a link to the tutorial I’ve been using:

And here is the snippet of the code which seems to be causing this error:

.AddOpenIdConnect("Auth0", options =>
        {
            // ...
            // options.ClientId = "mvc";
            options.Events = new OpenIdConnectEvents
            {
                // handle the logout redirection
                OnRedirectToIdentityProviderForSignOut = (context) =>
                {
                    var logoutUri = $"https://{Configuration["Auth0:Domain"]}/v2/logout?client_id={Configuration["Auth0:ClientId"]}";

                    var postLogoutUri = "https://localhost:44351/";
                    if (!string.IsNullOrEmpty(postLogoutUri))
                    {
                        if (postLogoutUri.StartsWith("/"))
                        {
                            // transform to absolute
                            var request = context.Request;
                            postLogoutUri = request.Scheme + "://" + request.Host + request.PathBase + postLogoutUri;
                        }
                        logoutUri += $"&returnTo={ Uri.EscapeDataString(postLogoutUri)}";
                    }

                    context.Response.Redirect(logoutUri);
                    context.HandleResponse();

                    return Task.CompletedTask;
                }
            };
        });

I have just resolved this issue. Thanks for reaching out to help yesterday but I was already done for the night. I have ran into another problem (of course) since resolving this issue, so I will open another issue if I can’t figure this one out before long. I know these are simple errors, but I’m brand new to this framework so I’m not always quick to figure out what the errors are or how to resolve them.