im currently working on incoroporate Google Login on Identity Server 3. Im using Microsoft.Owin.Security.Google but im struggling on what button do i have to put on my html to use google login. My code in my StartupClass is the following:`
public void Configuration(IAppBuilder app)
{
var baseAddress = ConfigurationManager.AppSettings["baseAddress"];
var identityAddress = ConfigurationManager.AppSettings["identityAddress"];
var logoutUrl = ConfigurationManager.AppSettings["postLogoutRedirect"];
var company = ConfigurationManager.AppSettings["ApplicationCompany"];
app.Map(
"/identity",
coreApp =>
{
coreApp.Use(async (context, next) =>
{
var language = context.Request.Query[_languageKey];
if (language != null)
{
context.Response.Cookies.Append(_languageKey, language);
}
else
{
language = context.Request.Cookies[_languageKey];
}
if (_cultureNames.Contains(language))
{
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(language);
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(language);
}
await next();
});
coreApp.UseIdentityServer(
new IdentityServerOptions
{
SiteName = company,
SigningCertificate = Cert.Load(),
Factory = IdentityServerFactoryConfig.BuildIdentityServerFactory(),
RequireSsl = true,
AuthenticationOptions = new IdentityServer3.Core.Configuration.AuthenticationOptions()
{
EnableLocalLogin = true,
IdentityProviders = ConfigureAdditionalIdentityProviders,
EnableSignOutPrompt = false,
EnablePostSignOutAutoRedirect = true,
PostSignOutAutoRedirectDelay = 0
},
ProtocolLogoutUrls = new List<string>()
{
logoutUrl
},
DiscoveryOptions = new DiscoveryOptions
{
ShowIdentityScopes = false,
ShowResourceScopes = false,
ShowClaims = false
},
EnableWelcomePage = false,
CspOptions = new CspOptions
{
FontSrc = identityAddress + " " + baseAddress,
StyleSrc = identityAddress + " " + baseAddress,
ScriptSrc = identityAddress + " " + baseAddress
}
});
});
}
private static void ConfigureAdditionalIdentityProviders(IAppBuilder app, string signInAsType)
{
var googleOptions = new GoogleOAuth2AuthenticationOptions
{
AuthenticationType = "Google",
SignInAsAuthenticationType = signInAsType,
ClientId = "clientId(its okay in my code)",
ClientSecret = "clientSecret(its okay in my code)",
CallbackPath = new PathString("/oauth-redirect"),
Provider = new GoogleOAuth2AuthenticationProvider()
{
OnAuthenticated = async context =>
{
var email = context.Identity.FindFirstValue(ClaimTypes.Email);
context.Response.Redirect($"http://localhost:7000/#/register-oauth?email={Uri.EscapeDataString(email)}");
//context.HandleResponse();
}
}
};
app.UseGoogleAuthentication(googleOptions);
}
` My idserver is running on localhost:44300. As you can see, the callback url is mapped on localhost:44300/identity/oauth-redirect, and this url is already in the google dev console. I have put this button on my html:
Google login
(i have put "identity/external" bcs the app maps from the begining in the url "identity")when i click, im getting the following error: {"Message":"No HTTP resource was found that matches the request URI 'https://localhost:44300/identity/external?provider=Google'.","MessageDetail":"No action was found on the controller 'Authentication' that matches the request."}
The idea after login is redirect to a component taking the user email. Im pretty lost on this error, what shoul i do?