Potential issue with Amazon Kendra boto3 API

0

I am getting this error when calling kendra_client.retrieve: An error occurred (AccessDeniedException) when calling the Retrieve operation: The provided JSON token isn't valid. The username couldn't be parsed. Generate a new token with username as an array of strings and try your request again. Below you can find the code snippet:

    token = {
        'username': 'me@myself.com',
        'groups': ['data.test1', 'data.default.owners', 'data.default.viewers', 'data.integration.test']
    }
    kendra_client = boto3.client("kendra", os.environ.get('AWS_REGION'))
    response = kendra_client.retrieve(
        IndexId=kendra_index_id,
        QueryText=question,
        AttributeFilter=attribute_filter,
        UserContext={'Token': json.dumps(token)}
    )

However, if I swap the values of username and groups (as shown below), everything works perfectly fine.

    token = {
        'username': ['data.test1', 'data.default.owners', 'data.default.viewers', 'data.integration.test'],
        'groups': 'me@myself.com'
    }

I am using version 1.28.63 of boto3.

I am under Basic Support plan, so I cannot open a ticket. Can anyone report this issue? Thanks a lot.

asked 5 months ago104 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions

Relevant content