Hi,
I have used below Configuration in identity server 4
public class Config
{
// scopes define the resources in your system
public static IEnumerable
{
return new List
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResources.Email(),
new IdentityResource
{
Name = "role",
UserClaims = new List
}
};
}
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource
{
Name = "customAPI",
DisplayName = "Custom API",
Description = "Custom API Access",
UserClaims = new List<string> {"role"},
ApiSecrets = new List<Secret> {new Secret("scopeSecret".Sha256())},
Scopes = new List<Scope>
{
new Scope("customAPI.read"),
new Scope("customAPI.write")
}
}
};
}
// clients want to access resources (aka scopes)
public static IEnumerable<Client> GetClients()
{
// client credentials client
return new List<Client>
{
new Client
{
ClientId = "oauthClient",
ClientName = "Example Client Credentials Client Application",
AllowedGrantTypes = GrantTypes.ClientCredentials,
ClientSecrets = new List<Secret>
{
new Secret("superSecretPassword".Sha256())
},
AllowedScopes = new List<string> {"customAPI.read"}
},
new Client
{
ClientId = "openIdConnectClient",
ClientName = "Example Implicit Client Application",
AllowedGrantTypes = GrantTypes.Implicit,
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
"role",
"customAPI"
},
RedirectUris = new List<string> {"https://localhost:44330/signin-oidc"},
PostLogoutRedirectUris = new List<string> { "https://localhost:44330" }
}
};
}
}
and i am using below code for MVC Client
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = "openIdConnectClient",
Authority = "https://localhost:44358",
SignInAsAuthenticationType = "Cookies",
ResponseType = "id_token",
Scope = "openid profile",
});
Please help me
<log goes here>
check the logs.
Where to find logs,also i am getting this error when i am trying cross version integration
Please help
read the docs ;)
This page is top hit from google. "Read the docs ;)" and "check the logs" are useless responses for others trying to diagnose the same issue. In future, can you please post links to relevant pages of the docs.
So I don't have an answer but I got some insight on the problem:
to see what the error code means I Injected the IIdentityServerInteractionService into my controllers constructor.
Added an extra function that accepts the errorId
public async Task<IActionResult> error(string errorId)
{
var errormessage = await identity.GetErrorContextAsync(errorId);
}
After I inspected the errorMessage object the message read
Invalid redirect_uri
and it seems my RedirectUri property is null
hope this helps someone.
but yes still don't have a proper solution
@SIkebe ah, woops. Removed it. Was more in line of "read further" type thought.
But yes, was able to get what my problem was. So the redirect URl that it used was /signin-oidc which i believe clashed with the fact the user is already logged in. We just opted to showing the user a page saying Email has been confirmed.
Pretty poor response from @leastprivilege. Would have expected better considering they build it. If I find useful info, I'll post it here to help others. Facing the same issue. Off to "Read the docs"...
For starters: http://docs.identityserver.io/en/latest/reference/options.html?highlight=errorId
Using Serilog is also useful: http://docs.identityserver.io/en/latest/topics/logging.html
In my case, my client configuration is invalid
[12:06:25 DBG] js found in database: True
[12:06:25 ERR] Invalid client configuration for client js: No redirect URI configured.
[12:06:25 ERR] Unknown client or not enabled: js
I've not found a way to user the errorId yet, but will update the comment if I find something.
Update:
Found some useful info here:
https://github.com/IdentityServer/IdentityServer4/issues/1002
and here:
Pretty poor response from @leastprivilege. Would have expected better considering they build it. If I find useful info, I'll post it here to help others. Facing the same issue. Off to "Read the docs"...
For starters: http://docs.identityserver.io/en/latest/reference/options.html?highlight=errorId
Using Serilog is also useful: http://docs.identityserver.io/en/latest/topics/logging.htmlIn my case, my client configuration is invalid
[12:06:25 DBG] js found in database: True
[12:06:25 ERR] Invalid client configuration for client js: No redirect URI configured.
[12:06:25 ERR] Unknown client or not enabled: jsI've not found a way to user the errorId yet, but will update the comment if I find something.
Update:
Found some useful info here:1002
and here:
@Quentinb Thanks for reference! It seems the actual View page for Error is missing in that repo. I wrote this code snippet and it works for me:
M
using IdentityServer4.Models;
namespace AuthServer.Models
{
public class ErrorViewModel
{
public ErrorMessage Error { get; set; }
}
}
V
@using AuthServer.Models
@{
ViewData["Title"] = "Error";
}
<h1>@ViewData["Title"]</h1>
<p>Error: @ViewBag.VM.Error.Error</p>
<p>Description: @ViewBag.VM.Error.ErrorDescription</p>
C
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authorization;
using IdentityServer4.Services;
using System.Threading.Tasks;
using AuthServer.Models;
namespace AuthServer.Controllers
{
[SecurityHeaders]
[AllowAnonymous]
public class HomeController : Controller
{
private readonly IHostingEnvironment _environment;
private readonly ILogger<HomeController> _logger;
private readonly IIdentityServerInteractionService _interaction;
public HomeController(IHostingEnvironment environment, ILogger<HomeController> logger, IIdentityServerInteractionService interaction)
{
_environment = environment;
_logger = logger;
_interaction = interaction;
}
public IActionResult Index()
{
if (_environment.IsDevelopment())
{
// only show in development
return View();
}
_logger.LogInformation("Homepage is disabled in production. Returning 404.");
return NotFound();
}
public IActionResult Privacy()
{
return View();
}
public async Task<IActionResult> Error(string errorId)
{
var vm = new ErrorViewModel();
// retrieve error details from identityserver
var message = await _interaction.GetErrorContextAsync(errorId);
if (message != null)
{
vm.Error = message;
}
ViewBag.VM = vm;
return View("Error", vm);
}
}
}
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
This page is top hit from google. "Read the docs ;)" and "check the logs" are useless responses for others trying to diagnose the same issue. In future, can you please post links to relevant pages of the docs.