abp icon indicating copy to clipboard operation
abp copied to clipboard

Google Login - GetExternalLoginInfoAsync returns null

Open krys-agentivity opened this issue 6 years ago • 3 comments

Hi,

My project use an IdentityServer4 service, an API service and a Blazor App. I try to add Google login, but the SignInManager.GetExternalLoginInfoAsync returns null.

I click the Google button, the Volo.Abp.Account.Web.Pages.Account.LoginModel.OnPostExternalLogin is well called, but the sign-in seems to cause an issue.

Do you have an idea to debug this ?

Here is my code from MyApplicationAccountWebIdentityServerModule:

            context.Services
                .AddAuthentication(options =>
                {
                    options.DefaultScheme = IdentityConstants.ApplicationScheme;
                    options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
                    options.RequireAuthenticatedSignIn = true;
                })
                .AddGoogle("Google", options =>
                {
                    // Configure here : https://console.developers.google.com/
                    options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
                    options.ClientId = clientConfig["Google:ClientId"];
                    options.ClientSecret = clientConfig["Google:ClientSecret"];
                })
                .AddIdentityCookies();

krys-agentivity avatar Jun 19 '20 15:06 krys-agentivity

Hello,

did you find a solution?

Best Regards

aelhadi avatar Feb 23 '21 09:02 aelhadi

What was the solution?

johnstaveley avatar Nov 13 '24 15:11 johnstaveley

For those who still looking for solution, it's not about startup config. you need to properly set Challenge properties while redirecting.

[HttpGet("/auth/signin/{provider}")]
public async Task<ActionResult<UserInfo>> SignInExternal(string provider, [FromQuery] string redirectUrl)
{
    return Challenge(
        properties: signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl), 
        authenticationSchemes: provider
    );
}

heysaad avatar Dec 05 '24 22:12 heysaad