fastapi-azure-auth icon indicating copy to clipboard operation
fastapi-azure-auth copied to clipboard

[BUG] got claim `acct` in type `int`, but fastapi-azure-auth is waiting for `str`

Open copdips opened this issue 1 year ago • 1 comments
trafficstars

With lastest version of FastAPI and Pydantic, When I got an access token from Azure, in the claims, the value for acct is a int to 0, but fastapi-azure-auth is waiting for str, could you please fix that:

https://github.com/Intility/fastapi-azure-auth/blob/52073693e1b59340d1e040b384b957dc61db0fd3/fastapi_azure_auth/user.py#L90

user: User = User(
                        **{**token, 'claims': token, 'access_token': access_token, 'is_guest': user_is_guest}
                    )
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/xxx/.venv/lib/python3.11/site-packages/pydantic/main.py", line 171, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for User
acct
  Input should be a valid string [type=string_type, input_value=0, input_type=int]
    For further information visit https://errors.pydantic.dev/2.6/v/string_type

copdips avatar Feb 15 '24 10:02 copdips

Azure doc: https://learn.microsoft.com/en-us/entra/identity-platform/optional-claims-reference#v10-and-v20-optional-claims-set

image

copdips avatar Feb 16 '24 15:02 copdips