I have a website running on ASP.NET MVC 4.5.2. I have an IdentityServer4 server running but when I try and authenticate against it I get an:
invalid_request
For ASP.NET Core MVC the documentation has:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = "oidc",
SignInScheme = "Cookies",
Authority = "http://localhost:5000",
RequireHttpsMetadata = false,
ClientId = "mvc",
SaveTokens = true
});
I am including the following NuGet package in my project Microsoft.Owin.Security.OpenIdConnect. My code is as follows:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
SignInAsAuthenticationType = "Cookies",
Authority = "http://localhost:5000",
ClientId = "mvc",
});
How would one correctly connect to it?
One would enable logging to find out what's really wrong.
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
SignInAsAuthenticationType = "Cookies",
Authority = "http://localhost:5000",
ClientId = "mvc",
});
should be
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
SignInAsAuthenticationType = "Cookies",
Authority = "http://localhost:5000",
RedirectUri = "http://localhost:5002/signin-oidc"
ClientId = "mvc",
});
RedirectUri = "http://localhost:5002/signin-oidc" needs to be specified even if it is defined in the Client.
@LiamSmithEngland Which file/sample is that in?
I based the sample off https://identityserver4.readthedocs.io/en/dev/quickstarts/3_interactive_login.html. As I am not using Core I tried to adapt it to use Microsoft.Owin.Security.OpenIdConnect over Microsoft.AspNetCore.Authentication.OpenIdConnect
Hi,
I writing to find out if someone managed to get this working, i'm currently having the same issue, I have current .Net 4.6.1 Web Api that I need to integrate to IdentityServer 4. I added Owin Middle-ware and the following code snippet from IdentityServer3 Resource/Scope Server in my attempt to make it work, but it's keeps on giving me 401 on Secured Api Call.
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = issuer,
RequiredScopes = new[] { scope }
});
Unfortunately I can't upgrade the api to use .net core since it's integrated with Soap Service which is not supported yet in .net core.
Open a new issue please with exact description of scenario.
Hi zngreg,
Were you able to find any solution for the Api issue that you were having. I created the following issue:
IdentityServer4 Bearer token authentication does not work with .net 4.5.2 Web Api #351
I have same issue. My web api can't understand the token that is generated by Identityserver5. I guess IdentityServer4 is supporting .NET 4.5.2. Is there any solution for that?
New issue and logs please
am also facing this issue , my sso proxy application developed by identityserver 4 with asp.net core, my few client applications are developed by core it's working fine, i try to include framework 4.5.2 developed client it throws error "Sorry, there was an error : invalid_request"
My client Code is
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
SignInAsAuthenticationType = "Cookies",
Authority = "http://localhost:4000", //ID Server SSO Server
ClientId = "Reportaldev",
ClientSecret = "secret",
ResponseType = "code id_token",
RedirectUri = "http://localhost:4002/signin-oidc", //URL of Client website
Scope = "apiportal",
AuthenticationMode= Microsoft.Owin.Security.AuthenticationMode.Active ,
});
I have the save problem, can anyone resolved it?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi,
I writing to find out if someone managed to get this working, i'm currently having the same issue, I have current .Net 4.6.1 Web Api that I need to integrate to IdentityServer 4. I added Owin Middle-ware and the following code snippet from IdentityServer3 Resource/Scope Server in my attempt to make it work, but it's keeps on giving me 401 on Secured Api Call.
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = issuer,
RequiredScopes = new[] { scope }
});
Unfortunately I can't upgrade the api to use .net core since it's integrated with Soap Service which is not supported yet in .net core.