首页 > 解决方案 > 如何通过 Keycloak REST API 获取访问令牌

问题描述

我正在尝试在我的 Spring Boot 应用程序中使用 Keycloak Rest API 获取访问令牌,
这是我使用 post 方法传入 Postman 的 URL,

http://localhost:8180/auth/realms/springboot/protocol/openid-connect/token ,

这里测试是我的领域,在正文部分作为 www-form-urlencoded 内容类型,我已经通过用户名,密码,client_id,grant_type 作为密码,我已经在管理控制台中完成了部分,还设置了领域和其他事情,响应我我正在邮递员中找不到 404,
预期的输出是访问令牌。

----
 here is my configuration in my app
keycloak.auth-server-url=http://localhost:8180/auth
keycloak.realm=springboot
keycloak.resource=springboot
keycloak.public-client=true
keycloak.security-constraints[0].authRoles[0]=user
keycloak.security-constraints[0].securityCollections[0].patterns[0]=/save/*
----

这是我得到的响应截图

标签: spring-bootkeycloak

解决方案


推荐阅读