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:
https://auth0.com/docs/quickstart/webapp/aspnet-core-3/01-login

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.

How did you resolve the issue? I get the same error.

I started back at the beginning of the tutorial and noticed that I had simply skipped over the section of code explaining how to specify the ClientID. Just above options.Events. I had another error immediately after resolving this one lol, but yeah you just have to specify ClientID (and if you are following the same tutorial I followed, look again carefully to see where they mention it in the tutorial).

1 Like

Yep try following the quickstart thoroughly and let us know if you still struggle with that. Most of the problems that happen with our quickstarts is that people do not follow them precisely step by step so maybe thatā€™s the case here too.

Thanks! I eventually fixed the problem by downloading the sample app and comparing the code to mine. I found out I was replacing the configuration values (e.g. Auth0:Domain) with the actual values from my profile. Silly me! Also, I didnā€™t include the application keys into my appsettings.json file. Iā€™m not sure it was mentioned in the tutorial, maybe it was considered obvious, but then again, Iā€™m a total noob at this. :smiley:

1 Like

Glad you have it working @mucomoc!

1 Like