Refresh token endpoint returning invalid credentials

Hello, I need help with my directus user authentication with nuxt… I am using SDK

return createDirectus(base).with(rest()).with(authentication('json'))

Then in my server route I am calling

const refreshToken = getCookie(event, 'refresh_token');
const response = await directus.request(refresh('json', refreshToken))

But directus is giving me:

"Invalid user credentials."

when calling this. Any ideas why? Could this be because of HTTP Only sameSite option? (I am storing both access and refresh tokens in HttpOnly cookies)

Have you verified that the refresh token from getCookie exists?

Can you please tell me how do I check this? I mean it exists in browser, i dont know if the refresh token exists in directus. I am using cloud version

1 Answer

1

refresh in the SDK does not take positional arguments; the signature is refresh(options), so refresh(‘json’, refreshToken) is the wrong shape here. With the call as is it falls back to mode: ‘cookie' by default. I believe this example should be await directus.request(refresh({ mode: 'json', refresh_token: refreshToken })) instead.