Hello team, I have two issues in production, so t...
# ask-a-descoper
m
Hello team, I have two issues in production, so this is top priority. 1. when the page get load, I see that this call https://auth.app.pillar.security/v1/auth/refresh?dcs=t&dcr=f return 400 and this error
Copy code
{
  "errorCode": "E011002",
  "errorDescription": "Request is missing required arguments",
  "errorMessage": "Missing JWT for refresh session",
  "message": "Missing JWT for refresh session"
}
2. When our users try to log out from the platform, they receive an error, and the page refreshes. The session doesn't end, and the UI does not log out. this call https://auth.app.pillar.security/v1/auth/logout get 400 and this error
Copy code
{
  "errorCode": "E064004",
  "errorDescription": "JWT not present for logout",
  "errorMessage": "Missing JWT for logout",
  "message": "Missing JWT for logout"
}
What should I do? This is not happening in the staging or local environment.
m
1. means you don't have a refresh cookie (since user did not login yet) , that 400 status code can be ignored
there is ability to switch to endpoint, that returns 200 for that check (try refresh) , adding @Asaf Shen on that
2. in order to logout, you need a jwt/token,no point in calling that one if you don't have any token (than you are not logged in)
m
1. But I see the error after the user is logged in. regardless 2, the user is logged in. He want to logout.
m
Can you check on both calls Are they made with a cookie called DSR ? You can see that on the HAR file
Also, might be good if you open a ticket with that HAR file on those
m
Ok. Will check.
I don't see DSR in my request, so what should I do? The user is logged in but can't log out.
c
Likely this relates to storage issues. Within the application data tab of the browser tools, do you see a DSR stored under the
auth.app.pillar.security
or
app.pillar.security
cookie?
m
I see DS not DSR.
a
it might be that the `DSR`is on cookie? if so, on which domain?
m
not sure what do you mean. this is my cookie. I don't see DSR.
a
in your project configuration - how do you manage refersh token?
m
image.png
a
1. what is the website domain? 2. what do you see in the request to descope that returns the token ? (usually its the
/next
request if you are using flow)
which API request is it? and the cookies response in this request?
Copy code
"cookieDomain": "app.pillar.security",
        "cookiePath": "/",
        "cookieMaxAge": 43199,
        "cookieExpiration": 1764797909,
a
there is also a cookies tab, (in chrome dev tools) the DSR cookie should be there, can you see it?
m
Yes. I see DSR.
a
so its arriving, can I login to your app to try to debug this later?
m
sure. need something from me?
a
I think you need to create a user for me (probably with a password)
m
Ok I will. the email is asaf@descope.com ?
a
Yes
m
done.
@Asaf Shen do you have update on this?
a
I will be available to look on 2 hours , I'll update
m
Thanks.
a
I just logged in and I am able to see both on the cookies
m
and you can logout?
The flow is as follows: After logging in, you will see both cookies. Click on "Sign Out." The page will refresh, but you will not be logged out. Then, you will only see the DS cookie.
a
I see that the DS is still there how do you determine if the user is authenticated? do you use Descope SDK hooks?
m
Yes, this is nextJS project. we are using
@descope/nextjs-sdk
and we also use the logout function from the SDK.
Also there is no issue in staging. Just in prod.
a
do you have differnet sdk versions between them?
m
Does the cookies should be removed one the user clicks on logout?
No. This is the same SDK.
a
I think its something with the way cookies are removed, let me think about this anyway - do. you use decope hooks to determine i the user is logged in?
m
Yes. I'm using functions from the descope package. This is happening in the SSR.
a
gotcha
I think the issue is somewhat in our side as a workaround, until we fix this (which will require a new sdk ) I suggest to run the following before calling descope's
sdk.logout()
Copy code
document.cookie = `DS=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=.${window.location.hostname}; secure`;
so your code should temporary do something like this
Copy code
import { useDesope 
const sdk = useDesope
m
Ok. I will try that.
a
Copy code
I think the issue is somewhat in our side

as a workaround, until we fix this (which will require a new sdk ) I suggest to run the following before calling descope's sdk.logout()
document.cookie = `DS=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=.${window.location.hostname}; secure`;

so your code should temporary do something like this

import { useDesope } from '@descope/nextjs-sdk/client'
...
   
   const sdk = useDesope()

   const doLogout = () => {
      // temporary workaround, until descope fixes the logout
      document.cookie = `DS=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=.${window.location.hostname}; secure`
       sdk.logout()
   }
  

   return <> <button onClick={doLogout}> sign-out</button> </>
}
m
Thanks. Any idea when you guys fix the issue?
a
m
@Asaf Shen what is the timeline for this to be released?
a
@Maor Bar the PR above solves the issue and likely to be merge today or in the next few days
(this will require you to update the
@descope/nextjs-sdk
package)
m
Thanks.
a
version
0.14.50
should contain the fix, let me know if there any feedback
m
Copy code
@descope/nextjs-sdk: 0.14.50
?
@Asaf Shen?
a
yes
m
Thanks.