GetExternalLoginInfoAsync() always return null.

Northern Lights asked on September 22, 2020 08:23

I have used Kentico's code from External authentication on MVC sites. ExternalLoginInfo loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); code is always return null.

Recent Answers

Arjan van Hugten answered on September 22, 2020 10:32 (last edited on September 22, 2020 10:33)

Which external authentication provider are you using? I've had some issues with the Azure AD login with openId Connect. Make sure all the settings in your Startup.Auth are correct. Below you can see my configuration for the 'OpenIdConnectAuthenticationOptions'. Also make sure that the 'MetadataAddress' uses the correct URL.

private OpenIdConnectAuthenticationOptions CreateOptionsFromPolicy(string policy)
    return new OpenIdConnectAuthenticationOptions
        // Generate the metadata address using the tenant and policy information
        MetadataAddress = string.Format(CultureInfo.InvariantCulture, GlobalsHelper.AadInstance, GlobalsHelper.Tenant, policy),
        AuthenticationType = policy,

        // Set any properties required by your authentication service
        ClientId = GlobalsHelper.ClientId,
        ClientSecret = GlobalsHelper.ClientSecret,
        RedirectUri = GlobalsHelper.RedirectUri,
        PostLogoutRedirectUri = GlobalsHelper.PostLogoutRedirectUri,
        AuthenticationMode = AuthenticationMode.Passive,
        ResponseType = OpenIdConnectResponseType.IdToken,

        Notifications = new OpenIdConnectAuthenticationNotifications
            AuthenticationFailed = OnAuthenticationFailed,
            RedirectToIdentityProvider = OnRedirectToIdentityProvider,
1 votesVote for this answer Mark as a Correct answer

Northern Lights answered on September 22, 2020 12:25

I have used google and facebook authentication.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.