Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

realmRoles Field required #101

Description

@ricciarellif

Using the examples provided, I'm unable to get the user's info through the route

http://localhost:8081/user/2b1b34f0-5efb-4cf8-b620-b619fd9b98bc (it's a valid user-id)

due to a pydantic error:

pydantic_core._pydantic_core.ValidationError: 1 validation error for KeycloakUser
realmRoles Field required [type=missing, input_value={'id': '2b1b34f0-5efb-4cf8-b620-b619fd9b98bc'...}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.1/v/missing

This is due to the absence, in the incoming json (Python dict), of the key "realmRoles" which is NOT always returned by the KeyCloak platform.

In your model.py module, class KeycloakUser(BaseModel), the realmRoles field is specified as "Optional" (realmRoles: Optional[List[str]]) but this attribute seems to be ignored by pydantic...

Any suggestion?
Thanks in advance

My requirements.txt:
fastapi==0.100.1
fastapi_keycloak==1.0.10
pydantic==2.2.1
uvicorn==0.23.1

My KeyCloack platform:
docker image of jsboss/keycloak:latest (Server version: 16.1.1) with postgresql 13.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions