Java KeyClope无法获取访问令牌

Java KeyClope无法获取访问令牌,java,spring,spring-boot,oauth-2.0,keycloak,Java,Spring,Spring Boot,Oauth 2.0,Keycloak,我正在尝试使用AuthzClient从Spring应用程序中的公共客户端获取访问令牌 代码如下: AuthzClient authzClient = AuthzClient.create(); AuthorizationRequest request = new AuthorizationRequest(); AuthorizationResponse response = authzClient.authorization(username, password)

我正在尝试使用
AuthzClient
从Spring应用程序中的公共客户端获取访问令牌

代码如下:

AuthzClient authzClient = AuthzClient.create();
AuthorizationRequest request = new AuthorizationRequest();
AuthorizationResponse response = authzClient.authorization(username, password)
                                .authorize(request);
String token = response.getToken();
但我一直收到这样的错误信息:

org.keydape.authorization.client.util.HttpResponseException:来自服务器的意外响应:400/错误请求/来自服务器的响应:{“错误”:“无效请求”,“错误描述”:“客户端不支持权限”}


有人能帮我找出我做错了什么吗?

首先,您需要为您的客户启用授权服务。因此,您应该转到管理控制台上的“客户端设置”页面,单击启用授权的
切换到
上的
,然后单击
保存
按钮

另见:

有多种方法可以检索KeyClope令牌。您是特别希望通过
AuthzClient
获取令牌,还是愿意以其他方式获取令牌?