Keycloak创建权限票据时一直面临(令牌`JsonToken.START_ARRAY`)问题。

huangapple go评论90阅读模式
英文:

Keycloak Creating permission ticket keep facing (token `JsonToken.START_ARRAY`)

问题

我想按照这里的说明创建权限票据,但在正确的请求体的情况下一直遇到以下错误:

> 未捕获的服务器错误:
> com.fasterxml.jackson.databind.exc.MismatchedInputException: 无法从数组值(令牌JsonToken.START_ARRAY)反序列化类型org.keycloak.representations.idm.authorization.PermissionTicketRepresentation

Postman请求的图片

有什么建议吗?

英文:

I want to create permission ticket following the instructions here but keep facing the below error while the body is correct:

> Uncaught server error:
> com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
> deserialize value of type
> org.keycloak.representations.idm.authorization.PermissionTicketRepresentation
> from Array value (token JsonToken.START_ARRAY)

Image of postman request

Any suggestions?

答案1

得分: 0

从文档中,权限票据接受一个简单的 JSON 对象:

{
"resource": "{resource_id}",
"requester": "{user_id}",
"granted": true,
"scopeName": "view"
}

但是在你的 Postman 请求中,你传递了一个 JSON 对象数组:

[{
"resource": "{resource_id}",
"requester": "{user_id}",
"granted": true,
"scopeName": "view"
}]

只需移除 '[' 和 ']' 并发送请求。

英文:

From the docs, Permission ticket accepts a simple json object

{
       "resource": "{resource_id}",
       "requester": "{user_id}",
       "granted": true,
       "scopeName": "view"
     }

But In your postman request, you are passing an Array Of JSON object

[{
       "resource": "{resource_id}",
       "requester": "{user_id}",
       "granted": true,
       "scopeName": "view"
     }]

Just remove the '[' and ']' and send the request.

huangapple
  • 本文由 发表于 2023年3月12日 19:54:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75712928.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定