https://supertokens.com/ logo
Title
e

execreate

10/20/2022, 1:34 PM
Hey guys, I'm having problems with the custom claims. I have a custom claim with key
2fa_completed_or_absent
. Everything is okay after I first log in, but after my access token expires (it is set to expire in 15 min) and I refresh my token there is a problem - I get this error from protected API endpoints:
json
{
    "message": "invalid claim",
    "claimValidationErrors": [
        {
            "id": "2fa_completed_or_absent",
            "reason": {
                "message": "wrong value",
                "expectedValue": true,
                "actualValue": false
            }
        }
    ]
}
When I try to decode the access token I can see that it contains the my custom claim and its value is correct:
json
{
  "2fa_completed_or_absent": {
    "v": true,
    "t": 1666271203895
  }
}
Do you think validation fails because of the timestamp? How do I avoid this?
Maybe I should change this function to change the TTL of the claim?
python
async def get_global_claim_validators(
        user_id: str,
        claim_validators_added_by_other_recipes: list[SessionClaimValidator],
        user_context: Dict[str, Any],
):
    return claim_validators_added_by_other_recipes + [SecondFactorCompletedOrAbsentClaim.validators.has_value(True)]
Oh sorry, looks like the value is actually false
json
{...
"2fa_completed_or_absent": {
    "v": false,
    "t": 1666273248592
}
...}
But why it becomes
False
after token refresh?πŸ€”
r

rp

10/20/2022, 2:08 PM
Hey! If the fetch_value function of the claim just returns false, then this used to happen in older versions of the SDK
Can you please update to the latest version of the SDKs and see if this solves the issue?
e

execreate

10/20/2022, 2:19 PM
I am currently using
supertokens-python==0.11.0
, I'll try to update it to the latest version now
r

rp

10/20/2022, 2:20 PM
Sounds good
e

execreate

10/20/2022, 2:20 PM
Well, looks like
supertokens-python==0.11.0
is already latest version πŸ˜…
r

rp

10/20/2022, 2:21 PM
Oh no it’s 0.11.3
e

execreate

10/20/2022, 2:22 PM
oh sorry, one sec
SDK upgrade fixed the issue πŸ₯³ thank you @rp πŸ™‚
r

rp

10/20/2022, 2:34 PM
Great!
You should also update the frontend SDK by the way.