Hi all. Question for descope team (I wasn't able t...
# ask-a-descoper
s
Hi all. Question for descope team (I wasn't able to find answers online) I am using
react-sdk
🙂 • Autorefresh is on by default? • How can I access
logout
functionality outside of
react-sdk
- I want to logout user in case of getting 401 from API multiple times and refreshing token is not succesfull Thanks for reply 🙏
o
logout - you can use the core-js or web-js sdk for simple logout functionality outside react
s
@orange-belgium-27264 thanks for quick reply 🙂 To use web-js-sdk I need to create initialise it again, right? Or is there any way I can access already initiated by react-sdk?
o
I’m confused - if your page is written with react, why not use the logout function in react?
s
API module is inside redux (rtk-query), we have custom error handler there. In case api fails with 401 we refresh token and try again. In case it fails again we want to logout user.
o
this is for the client that communicates with your backend, right? the 401 doesn’t come from Descope API but your own
s
True
o
so in that case, if the refresh fails, it means the user is already logged out from Descope, as the refresh token is invalid - no need to logout
if you would look at
isAuthenticated
for example it should be false at that point
if you keep a state of the user in other places, change that state too to reflect
s
Go it, thanks 🙏
birthday party parrot 1
o
my pleasure!