You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on a project where Keycloak is used for authentication, and I'm running into an issue that I can't seem to resolve. Here's a quick overview of my setup and the problem:
Environment:
Keycloak version: 26.2.4
Deployment: Coolify
Client Type: Confidential
Grant Type: client_credentials
Application framework: .NET Core
Issue Description:
`Attempting to get Keycloak admin token at 05/09/2025 06:05:00
Keycloak token endpoint: realms/PrimeCare/protocol/openid-connect/token
Using Keycloak realm: PrimeCare
Using clientId: keycloak-admin-api-client
clientSecret: *********************************
Token request parameters: grant_type=client_credentials, client_id=keycloak-admin-api-client
Sending token request to Keycloak
Create a separate HttpClient instance with cookies disabled specifically for token acquisition
Start processing HTTP request POST https://dev-cdashboard-api.asclepyus.com/keycloak/realms/PrimeCare/protocol/openid-connect/token
Received response from Keycloak token endpoint in -00:00:00.0000021ms: StatusCode=419
Response Header: Date=Fri, 09 May 2025 06:05:01 GMT
Response Header: Transfer-Encoding=chunked
Response Header: Connection=keep-alive
Response Header: Alt-Svc=h3=":443"
Response Header: Cache-Control=no-cache, private
Response Header: Server=cloudflare
Response Header: Nel={"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
Response Header: Cf-Cache-Status=DYNAMIC
Response Header: Report-To={"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=TOKy591nsdysYEXuLEd1ZoPbF64Skswu4WVourc%2BxGu%2Bu%2F0JYC2NghtjcXomrYTu8uRZllb3T%2F%2FpSz8I%2BoxMGDK14t1bKjsKI2z7x1NiM95deRQniOqTgmMBUqTYBGCQNhGrrveOO8ozAIsK%2FZ1Azgmn6A%3D%3D"}]}
Response Header: Set-Cookie=coolify_session=eyJpdiI6InExRENtYUdiOG5CeDVrQk5FS1gvc3c9PSIsInZhbHVlIjoiZWlaUm1McVFwQnJFOS8xb29kMzNGRWRuSjJjSmxoRU5nSy9CRHdpWGJxMndLb3dCczJQclRkcHRVR3BUbk5tSmhWVTROaTdJY2NEQ0RkTndXMmVZdXd0WEpzQWhqNnY2MUR4S3BlZ2VOUW5UREtHS1BudjJJK20yaG9Kek16VVUiLCJtYWMiOiIyYjljNmU4NjYxNDU1NGRlOWRlZmQ1MGMyMzY0ODg4Mzk2ZGU3NWJkMjM0NDk4NWI2ZWE0YzFjNTEyMGY5MGU4IiwidGFnIjoiIn0%3D; HttpOnly; SameSite=Lax; Secure; Path=/; Max-Age=604799; Expires=Fri, 16 May 2025 06:05:00 GMT
Response Header: CF-RAY=93cf00b07f2ef590-CDG HTTP request error while getting Keycloak admin token. StatusCode=419, Message=Response status code does not indicate success: 419 ()., Endpoint=realms/PrimeCare/protocol/openid-connect/token
Failed to ensure Keycloak authentication
PrimeCare.Application.Services.Keycloak.ErrorExceptions.KeycloakServiceException: Failed to get admin token: HTTP error 419 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 419 ().
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetConfidentialTokenAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 264
--- End of inner exception stack trace ---
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetConfidentialTokenAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 275
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.EnsureAuthenticatedAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 57
An unhandled exception has occurred while executing the request. PrimeCare.Application.Services.Keycloak.ErrorExceptions.KeycloakServiceException: Failed to get admin token: HTTP error 419
---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 419 ().
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetConfidentialTokenAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 264
--- End of inner exception stack trace ---
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetConfidentialTokenAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 275
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.EnsureAuthenticatedAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 57
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetResponseAsync(String endpoint) in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 85
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetAsync[T](String endpoint) in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 109
at PrimeCare.Application.Services.Keycloak.KeycloakOrganizationService.GetUserGroupsByIdAsync(String userId) in /src/PrimeCare.Application/Services/Keycloak/KeycloakOrganizationService.cs:line 137
at PrimeCare.Api.Middleware.CurrentUserMiddleware.InvokeAsync(HttpContext context, ICurrentUserService currentUserService, IKeycloakOrganizationService keycloakService) in /src/PrimeCare.Api/Middleware/CurrentUserMiddleware.cs:line 40
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
I'm currently working on a project where Keycloak is used for authentication, and I'm running into an issue that I can't seem to resolve. Here's a quick overview of my setup and the problem:
Environment:
Keycloak version: 26.2.4
Deployment: Coolify
Client Type: Confidential
Grant Type: client_credentials
Application framework: .NET Core
Issue Description:
`Attempting to get Keycloak admin token at 05/09/2025 06:05:00
Keycloak token endpoint: realms/PrimeCare/protocol/openid-connect/token
Using Keycloak realm: PrimeCare
Using clientId: keycloak-admin-api-client
clientSecret: *********************************
Token request parameters: grant_type=client_credentials, client_id=keycloak-admin-api-client
Sending token request to Keycloak
Create a separate HttpClient instance with cookies disabled specifically for token acquisition
Start processing HTTP request POST https://dev-cdashboard-api.asclepyus.com/keycloak/realms/PrimeCare/protocol/openid-connect/token
Request Headers:
Accept: application/json
User-Agent: Mozilla/5.0
Content-Type: application/x-www-form-urlencoded
Sending HTTP request POST https://dev-cdashboard-api.asclepyus.com/keycloak/realms/PrimeCare/protocol/openid-connect/token
Request Headers:
Accept: application/json
User-Agent: Mozilla/5.0
Content-Type: application/x-www-form-urlencoded
Received HTTP response headers after 190.8235ms - 419
Response Headers:
Date: Fri, 09 May 2025 06:05:01 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Alt-Svc: h3=":443"
Cache-Control: no-cache, private
Server: cloudflare
Nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
Cf-Cache-Status: DYNAMIC
Report-To: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=TOKy591nsdysYEXuLEd1ZoPbF64Skswu4WVourc%2BxGu%2Bu%2F0JYC2NghtjcXomrYTu8uRZllb3T%2F%2FpSz8I%2BoxMGDK14t1bKjsKI2z7x1NiM95deRQniOqTgmMBUqTYBGCQNhGrrveOO8ozAIsK%2FZ1Azgmn6A%3D%3D"}]}
Set-Cookie: coolify_session=eyJpdiI6InExRENtYUdiOG5CeDVrQk5FS1gvc3c9PSIsInZhbHVlIjoiZWlaUm1McVFwQnJFOS8xb29kMzNGRWRuSjJjSmxoRU5nSy9CRHdpWGJxMndLb3dCczJQclRkcHRVR3BUbk5tSmhWVTROaTdJY2NEQ0RkTndXMmVZdXd0WEpzQWhqNnY2MUR4S3BlZ2VOUW5UREtHS1BudjJJK20yaG9Kek16VVUiLCJtYWMiOiIyYjljNmU4NjYxNDU1NGRlOWRlZmQ1MGMyMzY0ODg4Mzk2ZGU3NWJkMjM0NDk4NWI2ZWE0YzFjNTEyMGY5MGU4IiwidGFnIjoiIn0%3D; HttpOnly; SameSite=Lax; Secure; Path=/; Max-Age=604799; Expires=Fri, 16 May 2025 06:05:00 GMT
CF-RAY: 93cf00b07f2ef590-CDG
Content-Type: application/json
End processing HTTP request after 192.2994ms - 419
Response Headers:
Date: Fri, 09 May 2025 06:05:01 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Alt-Svc: h3=":443"
Cache-Control: no-cache, private
Server: cloudflare
Nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
Cf-Cache-Status: DYNAMIC
Report-To: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=TOKy591nsdysYEXuLEd1ZoPbF64Skswu4WVourc%2BxGu%2Bu%2F0JYC2NghtjcXomrYTu8uRZllb3T%2F%2FpSz8I%2BoxMGDK14t1bKjsKI2z7x1NiM95deRQniOqTgmMBUqTYBGCQNhGrrveOO8ozAIsK%2FZ1Azgmn6A%3D%3D"}]}
Set-Cookie: coolify_session=eyJpdiI6InExRENtYUdiOG5CeDVrQk5FS1gvc3c9PSIsInZhbHVlIjoiZWlaUm1McVFwQnJFOS8xb29kMzNGRWRuSjJjSmxoRU5nSy9CRHdpWGJxMndLb3dCczJQclRkcHRVR3BUbk5tSmhWVTROaTdJY2NEQ0RkTndXMmVZdXd0WEpzQWhqNnY2MUR4S3BlZ2VOUW5UREtHS1BudjJJK20yaG9Kek16VVUiLCJtYWMiOiIyYjljNmU4NjYxNDU1NGRlOWRlZmQ1MGMyMzY0ODg4Mzk2ZGU3NWJkMjM0NDk4NWI2ZWE0YzFjNTEyMGY5MGU4IiwidGFnIjoiIn0%3D; HttpOnly; SameSite=Lax; Secure; Path=/; Max-Age=604799; Expires=Fri, 16 May 2025 06:05:00 GMT
CF-RAY: 93cf00b07f2ef590-CDG
Content-Type: application/json
Received response from Keycloak token endpoint in -00:00:00.0000021ms: StatusCode=419
Response Header: Date=Fri, 09 May 2025 06:05:01 GMT
Response Header: Transfer-Encoding=chunked
Response Header: Connection=keep-alive
Response Header: Alt-Svc=h3=":443"
Response Header: Cache-Control=no-cache, private
Response Header: Server=cloudflare
Response Header: Nel={"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
Response Header: Cf-Cache-Status=DYNAMIC
Response Header: Report-To={"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=TOKy591nsdysYEXuLEd1ZoPbF64Skswu4WVourc%2BxGu%2Bu%2F0JYC2NghtjcXomrYTu8uRZllb3T%2F%2FpSz8I%2BoxMGDK14t1bKjsKI2z7x1NiM95deRQniOqTgmMBUqTYBGCQNhGrrveOO8ozAIsK%2FZ1Azgmn6A%3D%3D"}]}
Response Header: Set-Cookie=coolify_session=eyJpdiI6InExRENtYUdiOG5CeDVrQk5FS1gvc3c9PSIsInZhbHVlIjoiZWlaUm1McVFwQnJFOS8xb29kMzNGRWRuSjJjSmxoRU5nSy9CRHdpWGJxMndLb3dCczJQclRkcHRVR3BUbk5tSmhWVTROaTdJY2NEQ0RkTndXMmVZdXd0WEpzQWhqNnY2MUR4S3BlZ2VOUW5UREtHS1BudjJJK20yaG9Kek16VVUiLCJtYWMiOiIyYjljNmU4NjYxNDU1NGRlOWRlZmQ1MGMyMzY0ODg4Mzk2ZGU3NWJkMjM0NDk4NWI2ZWE0YzFjNTEyMGY5MGU4IiwidGFnIjoiIn0%3D; HttpOnly; SameSite=Lax; Secure; Path=/; Max-Age=604799; Expires=Fri, 16 May 2025 06:05:00 GMT
Response Header: CF-RAY=93cf00b07f2ef590-CDG
HTTP request error while getting Keycloak admin token. StatusCode=419, Message=Response status code does not indicate success: 419 ()., Endpoint=realms/PrimeCare/protocol/openid-connect/token
Failed to ensure Keycloak authentication
PrimeCare.Application.Services.Keycloak.ErrorExceptions.KeycloakServiceException: Failed to get admin token: HTTP error 419
---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 419 ().
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetConfidentialTokenAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 264
--- End of inner exception stack trace ---
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetConfidentialTokenAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 275
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.EnsureAuthenticatedAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 57
An unhandled exception has occurred while executing the request.
PrimeCare.Application.Services.Keycloak.ErrorExceptions.KeycloakServiceException: Failed to get admin token: HTTP error 419
---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 419 ().
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetConfidentialTokenAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 264
--- End of inner exception stack trace ---
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetConfidentialTokenAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 275
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.EnsureAuthenticatedAsync() in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 57
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetResponseAsync(String endpoint) in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 85
at PrimeCare.Application.Services.Keycloak.Base.BaseKeycloakService.GetAsync[T](String endpoint) in /src/PrimeCare.Application/Services/Keycloak/Base/BaseKeycloakService.cs:line 109
at PrimeCare.Application.Services.Keycloak.KeycloakOrganizationService.GetUserGroupsByIdAsync(String userId) in /src/PrimeCare.Application/Services/Keycloak/KeycloakOrganizationService.cs:line 137
at PrimeCare.Api.Middleware.CurrentUserMiddleware.InvokeAsync(HttpContext context, ICurrentUserService currentUserService, IKeycloakOrganizationService keycloakService) in /src/PrimeCare.Api/Middleware/CurrentUserMiddleware.cs:line 40
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)`
All reactions