Spring cloud 登录到Spring Cloud Api网关后面的KeyClove

Spring cloud 登录到Spring Cloud Api网关后面的KeyClove,spring-cloud,keycloak,api-gateway,keycloak-rest-api,Spring Cloud,Keycloak,Api Gateway,Keycloak Rest Api,我在SpringCloudAPI网关后面运行了Key斗篷和一个微服务。我希望允许客户端应用程序执行/login HTTP请求,以允许用户使用用户名和密码登录 因为客户机应用程序将使用密码授予类型,通过RESTAPI使用keydepot进行身份验证,所以它将向keydepot/令牌端点发送HTTP Post请求 http://localhost:8080/auth/realms/<realm>/protocol/openid-connect/token 若我通过API网关发送HTTP

我在SpringCloudAPI网关后面运行了Key斗篷和一个微服务。我希望允许客户端应用程序执行/login HTTP请求,以允许用户使用用户名和密码登录

因为客户机应用程序将使用密码授予类型,通过RESTAPI使用keydepot进行身份验证,所以它将向keydepot/令牌端点发送HTTP Post请求

http://localhost:8080/auth/realms/<realm>/protocol/openid-connect/token
若我通过API网关发送HTTPPOST请求,我将得到404NotFound错误

curl --location --request POST 'http://localhost:8085/token-service' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=username' \
--data-urlencode 'password=mypassword' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id=my-spring-cloud-api-gateway' \
--data-urlencode 'client_secret=3c832be7-2950-4490-801e-276b874d3dd3'
如果我将SpringCloudAPI网关配置为将此HTTPPOST请求路由到本地主机上运行的另一个微服务,那么一切都可以正常工作。如果我不使用API网关并将上述HTTP Post请求直接发送到KeyClope端点http://localhost:8080/auth/realms/myrealm/protocol/openid-连接/token,然后我得到一个访问令牌。因此keydepot正在运行,OAuth客户端应用程序被配置为使用密码授权

只有通过API网关发送上述请求并使网关将请求路由到KeyClope端点时,才会发生404错误代码http://localhost:8080/auth/realms/myrealm/protocol/openid-连接/令牌

我做错了什么


谢谢大家!

你能解决这个问题吗?你能解决这个问题吗?
curl --location --request POST 'http://localhost:8085/token-service' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=username' \
--data-urlencode 'password=mypassword' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id=my-spring-cloud-api-gateway' \
--data-urlencode 'client_secret=3c832be7-2950-4490-801e-276b874d3dd3'