Description
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",
),
)