reactjs - 如何在 keycloak 的 REST API 中使用身份提供者?
问题描述
我目前正在从我自己的“组合”身份验证系统切换到 keycloak。我目前在试图弄清楚如何使用身份提供者通过 keycloak 登录时遇到了一些困难。到目前为止,我能够使用其余 API 轻松添加身份提供者:http://localhost:8080/auth/admin/realms/test/users
{"firstName":"FIRSTNAME","lastName":"LASTNAME", "enabled":"true", "username":"app-user", "federatedIdentities": [{"identityProvider": "google", "userId": "XXXXXXXXXXXXXX", "userName": "XXXX XXXXXXXXXXXX"}]}
在进入管理面板并通过他们的网络界面登录后,一切似乎都正常了。
我目前正在尝试使用 REST API 登录,但我不断收到以下错误
{
"error": "invalid_grant",
"error_description": "Code not valid"
}
使用以下 URL 和参数
http://localhost:8080/auth/realms/test/protocol/openid-connect/token
clinet_id=test
grant_type=authorization_code
code=XXXX(pulled from frontend using react-social-login)
redirect_uri=http://localhost:8080/redirect
client_secret=XXXXXX
任何帮助将不胜感激,因为我希望能够使用 REST API 完成所有登录,如果您还建议切换到最适合我的应用程序的东西(从前端传递信息并在后端授权),请告诉我.
解决方案
推荐阅读
- android - 应用程序在 android studio 模拟器上运行但不在真实设备上:(
- python - 通过执行依赖于多个索引的操作来创建列表 - python
- highcharts - 根据不规则数据绘制 Highcharts 热图
- meteor - 如何从命令行调用 Meteor 方法
- spring - Spring OAuth2 在成功验证时重定向到原始 URL
- jquery - 使用 jquery 每 5 秒倒计时
- python - 单从多拆分
- elasticsearch - Elasticsearch 排除对字段值的最高命中
- java - 从数据库 Spring Boot 获取详细信息,异常错误
- swift - 使用 GKStates 和 PhysicsBody 操作的最佳实践