英文:
How to create keyclock clientSecret via API
问题
我正在使用Keycloak版本20.0.2,并想知道是否可以通过POST请求(/admin/realms/:realm/clients/:id/client-secret)创建clientSecret。
我想要通过POST请求发送包含我自己生成的client secret值的请求体。
请求URL:
https://{host}/admin/realms/{realm}/clients/{id}/client-secret
请求体:
{
"clientSecret": "我自己生成的值在这里"
}
响应:
{
type: "secret",
value: "我自己生成的值在这里"
}
英文:
I’m using keycloak version 20.0.2, and I want to know if it possible to create clientSecret through a post request (/admin/realms/:realm/clients/:id/client-secret).
I want to send body to post request with my own generated client secret value
https://{host}/admin/realms/{realm}/clients/{id}/client-secret
Body: {
"clientSecret":"my own generated value here"
}
Response: {
type: "secret",
value: "my own generated value here"
}
答案1
得分: 1
您有两个选项。
#1 创建一个带有自己密钥的新客户端 API
#2 可以通过 Keycloak 在现有客户端上生成随机密钥
但没有选项可以使用您自己的方式更新客户端密钥。
#1 创建一个带有自己密钥的新客户端 API
POST {Keycloak URL}/admin/realms/test/clients
请求体
{
"clientId": "<新客户端ID>",
"name": "<客户端名称>",
"enabled": true,
"clientAuthenticatorType": "client-secret",
"secret": "<我的自己的密钥>"
}
请求体
{
"clientId": "Test-Client",
"name": "Test-Client-New",
"enabled": true,
"clientAuthenticatorType": "client-secret",
"secret": "my-new-own-secret"
}
#2 通过 Keycloak 随机生成密钥
POST {Keycloak URL}/admin/realms/{我的领域}/clients/{客户端UUID}/client-secret
输入请求体
None
响应体
{
"type": "secret",
"value": "<由 Keycloak 随机创建的新密钥>"
}
英文:
You have two options.
#1 One is create new client API with own secret
#2 Second is can random generated secret on existing client by Keycloak
But no option update the client secrete with your own.
#1 One is create new client API with own secret
POST {Keycloak URL}/admin/realms/test/clients
Body
{
"clientId": <new client ID>,
"name": <Cleint Name>,
"enabled": true,
"clientAuthenticatorType": "client-secret",
"secret": <my-own-secret>
}
In Body
{
"clientId": "Test-Client",
"name": "Test-Client-New",
"enabled": true,
"clientAuthenticatorType": "client-secret",
"secret": "my-new-own-secret"
}
#2 Second is can random generated secret by Keycloak
POST {Keycloak URL}/admin/realms/{my-realm}/clients/{client-uuid}/client-secret
Input Body
None
Response Body
{
"type": "secret",
"value": <Random created new secret by Keycloak>
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论