i am using the self service login flow for my reac...
# talk-kratos
e
i am using the self service login flow for my react native application, is there a way to refresh the token without asking user to login again, while the app is active? or i have to handle by writing custom client code for keep alive? #kratos
d
The way we solved this was to make an endpoint on our own API, which uses Kratos Admin’s extend session endpoint
e
@dazzling-napkin-4938 that's great, can you please explain how did you go about doing it? like the flow in which your UI and backend were communicating
d
It’s pretty simple really - our requirements are that the user stays logged in for up to 14 days without using the app. So we have Kratos issue sessions that expire after 14 days. Each time the app starts: • Query Kratos
/whoami
to see if the app is currently logged in • if the user is logged in, make an authenticated request to our API
/extendSession
endpoint • Our API calls
/admin/sessions/id/extend
, which extends the lifetime of the session token
e
awesome! this helps thanks for helping @dazzling-napkin-4938!
d
no worries. Depending on the usage patterns of your app, you might find that extending the session every startup is too much, so you can use
earliest_possible_extend
to only extend after a period of time, for example
e
cool got it!
@dazzling-napkin-4938 just clarifying one more thing, in order to increase the session time did you used
lifespan: 14d
in identityconfig?
d
yes