Skip to content

Custom third party provider id_token values override the expected values #552

Open
@mavwolverine

Description

@mavwolverine

I want only values from user_info API response. Used this configuration.

    input.config.user_info_map = UserInfoMap(
        from_id_token_payload=UserFields(),
        from_user_info_api=UserFields(
            user_id="id",
            email="userPrincipalName",
        ),
    )

But the third_party_user_id and email are not the expected values.

Was able to trace it to https://github.com/supertokens/supertokens-python/blob/master/supertokens_python/recipe/thirdparty/providers/custom.py#L101 where after getting the value from user info API, it again gets the value from id_token and overrides it.

But since, I set from_id_token_payload=UserFields(), that should not be happening.

https://github.com/supertokens/supertokens-python/blob/master/supertokens_python/recipe/thirdparty/providers/custom.py#L235 is setting the value to sub, and since the id_token has sub field set, it overrides the id value from the user_info_api.

I think the logic needs to be something like,

  • if from_user_info_api config is set, get values.
  • if from_id_token_payload config is set, get values.
  • if no values are found, try with default values for from_user_info_api
  • if no values are found, try with default values for from_id_token_payload

Right now, the only workaround I can think of

    input.config.user_info_map = UserInfoMap(
        from_id_token_payload=UserFields(
            user_id="XYZ",  # some value which will never be in id_token
            email="XYZ",  # some value which will never be in id_token
        ),
        from_user_info_api=UserFields(
            user_id="id",
            email="userPrincipalName",
        ),
    )

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