By: Steven Toth user 09 Feb 2022 at 10:31 a.m. CST

2 Responses
Steven Toth gravatar
Hello, I'm trying to generate an Access Token that meets the requirements of a third party application. The Access Token must have a claim with a nested structure as such: ``` { ... "resource_access": { "<client id>": { "roles": [ "<role name>" ], "<attribute name>": "<attribute value>" } ... } ``` I'm able to use an Introspection script to add an Array, String or other type, but when I try to add a JSONObject (specifically org.codehaus.jettison.json.JSONObject) I get an exception. Code from the Introspection script: ``` from org.codehaus.jettison.json import JSONObject ... def modifyResponse(self, responseAsJsonObject, context): client_info = JSONObject('{ "client_id_1": { "roles": ["some_role"], "attribute_1": "some value" } }') responseAsJsonObject.accumulate("resource_access", client_info) return True ``` Error from Gluu logs: 2022-02-08 16:46:29,330 ERROR [qtp1224347463-1420] [org.gluu.oxauth.model.common.AuthorizationGrant] (AuthorizationGrant.java:199) - Claim value is not supported, key: resource_access, value :{"client_id_1":{"roles":["some_role"],"attribute_1":"some value"}} java.lang.UnsupportedOperationException: Claim value is not supported, key: resource_access, value :{"client_id_1":{"roles":["some_role"],"attribute_1":"some value"}} Am I missing something? Do I need to define the structure somewhere (local LDAP?) ahead of time, set the value a different way, or does Gluu not support this type of nested structure? I also tried using dot notation for the key name (ex. resource_access.client_id_1.roles) in hopes that the strucutre in the token would be reflective of that, but it did not work as the key name is taken literally. Thanks.

By Yuriy Zabrovarnyy staff 09 Feb 2022 at 11:02 a.m. CST

Yuriy Zabrovarnyy gravatar
In 4.3 we are using `org.json.JSONObject` under the hood. Thus using something like below should help. ``` from org.json import JSONObject client_info = JSONObject('{ "client_id_1": { "roles": ["some_role"], "attribute_1": "some value" } }') responseAsJsonObject.accumulate("resource_access", JSONObject) ```

By Steven Toth user 09 Feb 2022 at 11:43 a.m. CST

Steven Toth gravatar
Thank you for the quick response. I switched the type and it worked. Thank you very much!