Hi, I'm using SuperToken in ReactNative, Can you guide me on, how to manage a session with a refresh...
j
Hi, I'm using SuperToken in ReactNative, Can you guide me on, how to manage a session with a refresh token? In docs, they are only mentioning to add the init function and addAxiosInterceptors. I tried those, but the session got timed out after some time.
r
Hey @josephmilanmd
you need to make sure you have set the correct apiDomain value on the frontend in supertokens.init
it should point to the server in which you have integrated our backend SDK
j
They are correct, I'm getting a valid token, but after 30mins and so it got timed out. It is not using refresh token to refresh the session.
r
are you querying the same API that you have set for the value of apiDomain?
can you share the request headers with me?
the one that causes a 401 response
j
Can you rephrase?
r
you are making an api call that returns a 401 right?
j
I'm getting a vaild token at the time of login and after 30mins the token became undefined, then api response status code will be 401 and response will be { "message": "try refresh token" }
r
yea, so what are the request headers of this API call
j
when there is a valid token, then the request will be {"adapter": ["xhr", "http"], "baseURL": "", "env": {"Blob": [Function Blob], "FormData": [Function FormData]}, "headers": {"Accept": "application/json, text/plain, */*", "Content-Type": "application/json"}, "maxBodyLength": -1, "maxContentLength": -1, "method": "get", "params": {"page_num": 1, "page_size": 10, "status_in": "assigned"}, "timeout": 0, "transformRequest": [[Function transformRequest]], "transformResponse": [[Function transformResponse]], "transitional": {"clarifyTimeoutError": false, "forcedJSONParsing": true, "silentJSONParsing": true}, "url": "leads", "validateStatus": [Function validateStatus], "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN"} if the token expires, then the request will be {"adapter": ["xhr", "http"], "baseURL": "", "env": {"Blob": [Function Blob], "FormData": [Function FormData]}, "headers": {"Accept": "application/json, text/plain, */*", "Content-Type": "application/json"}, "maxBodyLength": -1, "maxContentLength": -1, "method": "get", "params": {"page_num": 1, "page_size": 10}, "timeout": 0, "transformRequest": [[Function transformRequest]], "transformResponse": [[Function transformResponse]], "transitional": {"clarifyTimeoutError": false, "forcedJSONParsing": true, "silentJSONParsing": true}, "url": "leads", "validateStatus": [Function validateStatus], "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN"}
r
Can you enable frontend debug logs and show thr output when making the api call?
j
okay let me try
[Error: Request failed with status code 403]
r
U need to enable frontend debug logs please
j
In react native right?
r
Yes o
j
Could you please clarify what specifically you're looking for?
what output you want?
Enable the debug logs, and then show me the output when you make the api call that returns 401
j
there is one for react but nothing for react native
r
Click on custom ui on the top right
Blue box
j
okay got it
r
I’ll check it out on Monday and get back
hey @josephmilanmd can i see all the request headers being made in ths API call thet returns a 401?
j
yes
What should I do?
r
show me the request headers of the API call that is being made.
j
this is the request headers
r
how did you get them? The logs show that the auth header is being added, but the headers dont contain it.
j
in the code I just added SuperToken.addAxiosIntersecptor()
2 Views