简体   繁体   English

Keycloak无法获取访问令牌

[英]Keycloak unable to get access token

I'm trying to use AuthzClient to obtain an access token from a public client in my Spring app. 我正在尝试使用AuthzClient从Spring应用程序中的公共客户端获取访问令牌。

Here is the code: 这是代码:

AuthzClient authzClient = AuthzClient.create();
AuthorizationRequest request = new AuthorizationRequest();
AuthorizationResponse response = authzClient.authorization(username, password)
                                .authorize(request);
String token = response.getToken();

But I keep getting this error message: 但我不断收到此错误消息:

org.keycloak.authorization.client.util.HttpResponseException: Unexpected response from server: 400 / Bad Request / Response from server: {"error":"invalid_request","error_description":"Client does not support permissions"} org.keycloak.authorization.client.util.HttpResponseException:服务器意外响应:400 /错误请求/服务器响应:{“错误”:“ invalid_request”,“ error_description”:“客户端不支持权限”}

Can someone please help me figure out what I'm doing wrong? 有人可以帮我弄清楚我在做什么错吗?

First you need to enable authorization service for your client. 首先,您需要为客户启用授权服务。 So you should go to your client settings page on the admin console and click the Authorization Enabled switch to ON , and then click Save button. 因此,您应该转到管理控制台上的客户端设置页面,然后将“已Authorization Enabled开关单击为ON ,然后单击“ Save按钮。

See also: Keycloak Authorization Services Guide - 2.3. 另请参阅: Keycloak授权服务指南-2.3。 Enabling Authorization Services 启用授权服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM