Auth0 Home Blog Docs

ASP.NET Core 2 not working with embedded Lock: Getting "Exception: Correlation failed."

lock
aspnet-core

#1

Hi

I am trying to use the embedded Lock v11 control with asp.net core. For the server side, I have setup based on the sample provided here: https://auth0.com/docs/quickstart/webapp/aspnet-core/01-login. Note that it is working for me when I use the following approach:

public async Task Login(string returnUrl = "/")
{
    await HttpContext.ChallengeAsync("Auth0", new AuthenticationProperties() { RedirectUri = returnUrl });
}

However, when I try to login using Lock embedded in my cshtml, I get the following error:

Here is my front end code:

$(function () {

            var originUrl = "@($"{Context.Request.Scheme}://{Context.Request.Host}")";
            var callbackUrl = originUrl + "/signin-auth0";
            var logoUrl = originUrl + "/images/logo.png";

            var lock = new Auth0Lock(
                '@Model.Auth0.ClientId',
                '@Model.Auth0.Domain',
                {
                    container: 'root',
                    theme: {
                        logo: logoUrl,
                        primaryColor: '#0064D2'
                    },
                    languageDictionary: {
                        title: "Secure Messaging"
                    },
                    auth: {
                        redirectUrl: callbackUrl,    // If not specified, defaults to the current page 
                        responseType: 'code',
                        //responseMode: 'form_post',
                        sso: true,
                        params: {
                            scope: 'openid name profile email roles'
                        }
                    },
                    allowForgotPassword: true
                }
            );

            lock.show();
     });

Note that this was kind-of reported in this topic, but was closed without resolution: Embedded lock with ASP.Net Core 2.0

Thanks in advance
Zawar