Hi guys, I have a custom endpoint that updates JWT token payload. It returns new cookie for cookie-based clients and new headers for header based. For cookie-based clients it works out of the box (well, it's just a set-cookie). What to do with header-based clients? How to tell supertokens (react / react-native) SDK to "update your token to this one"? Tnx!
r
rp_st
08/03/2023, 7:19 AM
hey @vyobukhov it should work for header based as well on its own as long as:
- our network interceptors are running on the frontend
- The response headers have
st-access-token
and
front-token
- Right values for access control expose headers
v
vyobukhov
08/03/2023, 7:20 AM
Yeah, thx, I see that there is a saveTokensFromHeaders fn. Will try to find out why it doesn't work for me properly (fn get's called)
r
rp_st
08/03/2023, 7:20 AM
hmm ok.
v
vyobukhov
08/03/2023, 7:36 AM
ok, it works but uses stale token for new requests. Trying to find the issue...
r
rp_st
08/03/2023, 7:37 AM
hmm. that's odd. Are the tokens in the browser storage being updated? (They are stored in frontend cookies)
v
vyobukhov
08/03/2023, 7:38 AM
I have a react-native client. (Browser clients use cookie-mode, so no issues there). Checking
vyobukhov
08/03/2023, 10:07 AM
I just a had a race condition in a code. Problem resolved, thx!
SuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).