locked
Problem authenticating with OpenIdConnect RRS feed

  • Question

  • User-484626426 posted

    Hi guys,

    I'm very new to OpenIdConnect. I was using Live SDK application to as one of the external authentication methods but unfortunately it's deprecating.

    I've set up app registration at Azure for authentication but apparently it won't authenticate.

    After the user enters a Microsoft username and password, the user is directed back to the website https://iluvrun.com/Account/RegisterExternalLogin?providerName=OpenIdConnect&returnUrl=. When I checked Context.GetOwinContect().Authentication.GetExternalLoginIndo() at RegisterExternalLogin.cs, it returns null.

    I also checked the user's apps and services given access, the app is listed there. So it did authenticate and was given access.

    Following the guide, this is what I have at Startup.Auth.cs

    public void ConfigureAuth(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

        app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                ClientId = "[client_id]",
                Authority = "https://login.microsoftonline.com/[tenant_id]/v2.0",
                RedirectUri = "https://iluvrun.com/signin-oidc",
                PostLogoutRedirectUri = "https://iluvrun.com",
                Scope = OpenIdConnectScope.OpenIdProfile,
                ResponseType = "id_token",
                TokenValidationParameters = new TokenValidationParameters()
                TokenValidationParameters = new TokenValidationParameters()
                {
                    ValidateIssuer = false
                },
                    Notifications = new OpenIdConnectAuthenticationNotifications
                {
                    AuthenticationFailed = OnAuthenticationFailed
                }
            }
        );
    }

    private Task OnAuthenticationFailed(AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> context)
    {
        context.HandleResponse();
        context.Response.Redirect("/?errormessage=" + context.Exception.Message);
        return Task.FromResult(0);

    }

    Saturday, April 11, 2020 11:24 AM

All replies

  • User1535942433 posted

    Hi suencien,

    Accroding to your description,as far as I think,I suggest you need to enable the application to use a cookie to store information for the signed in user and use a cookie to temporarily store information about a user logging in with a third party login provider.

    More details,you could refer to below article:

    https://stackoverflow.com/questions/43112871/getexternallogininfo-returns-null

    Best regards,

    Yijing Sun

    Monday, April 13, 2020 5:39 AM