You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IdentityServer4始终返回invalid_client错误排查求助

Troubleshooting "invalid_client" Error in IdentityServer4 Client Credentials Flow

Hey everyone, I'm new to IdentityServer4 and currently trying to integrate it into my website. I've hit a frustrating roadblock that I can't resolve on my own, so I'm reaching out for some guidance.

I've configured a client in IdentityServer and attempted to request a token via the client credentials flow. Even after double-checking my ClientId, ClientSecret, and Scope countless times, I keep getting an "invalid_client" error. I suspect there's a missing piece in my client configuration, but I can't pinpoint what it is.

Here's the code I'm using to request the token:

var serverClient = new HttpClient();
var discoveryDocument = await serverClient.GetDiscoveryDocumentAsync(authServerURL); //discoveryDocument is ok!
var tokenResponse = await serverClient.RequestClientCredentialsTokenAsync(
    new ClientCredentialsTokenRequest
    {
        Address = discoveryDocument.TokenEndpoint,
        ClientId = "myClient",
        ClientSecret = "mySecret",
        Scope = "openid",
    });
if (tokenResponse.IsError) {
    //always true! error: invalid_client
    throw new Exception(tokenResponse.Error);
}

Additional Client Setup Details

I created my client by copying an existing default client through the Skoruba IdentityServer UI. Here are the key configurations I've set:

  • Client name is correctly filled out
  • Basic settings (ClientId and ClientSecret) have been verified repeatedly, and the secret is definitely correct
  • For token settings, I've configured Allowed CORS to target my local API instance, and I've also tried leaving this field empty—neither change fixes the issue

Could anyone help me troubleshoot this problem? I'd really appreciate it!

Dario.

内容的提问来源于stack exchange,提问作者skini82

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 20:49:05