英文:
Keycloak Java Client Get Fetching Token
问题
我需要获取rpt以便在我的应用程序中注册新用户。
Keycloak.json
{
"realm": "master",
"auth-server-url" : "http://localhost:8180/auth",
"resource" : "admin-cli",
"public-client": true
}
获取rpt:
@GetMapping("rpt")
public String token() {
var username = environment.getProperty("authServer.admin.username");
var password = environment.getProperty("authServer.admin.password");
var req = new AuthorizationRequest();
var res = this.authzClient.authorization(username, password).authorize(req);
return res.getToken();
}
我收到以下错误:java.lang.RuntimeException: 未提供客户端密钥。
但我正在使用位于主realm下的admin-cli
,其访问类型为public
。
我已经设置为:
"public-client": true
如何获取admin-cli
的rpt?我将在我的应用程序注册页面中使用它来创建新用户。
英文:
I need to obtain rpt in order to register new users in my app.
Keycloak.json
{
"realm": "master",
"auth-server-url" : "http://localhost:8180/auth",
"resource" : "admin-cli",
"public-client": true
}
Fetching the rpt:
@GetMapping("rpt")
public String token() {
var username = environment.getProperty("authServer.admin.username");
var password = environment.getProperty("authServer.admin.password");
var req = new AuthorizationRequest();
var res = this.authzClient.authorization(username, password).authorize(req);
return res.getToken();
}
I get:java.lang.RuntimeException: Client secret not provided.
But I am using admin-cli
that under the master realm which it's access type is public
.
Already I set:
"public-client": true
How can I obtain rpt of admin-cli
? I will use it to create new users in my applications register page.
专注分享java语言的经验与见解,让所有开发者获益!
评论