Refresh Token not received on login

Hello,

I am building a next js app with directus sdk. when i login with sdk method the refresh token is not returned. not sure if there is an extra setup required.

this is my setup so far.

directus.ts
import {
authentication,
createDirectus,
rest,
staticToken,
} from “directus/sdk”;
import { CustomDirectusTypes } from “../types/directusSchema”;

export const directus = (token: string = “”) => {
const client = createDirectus(baseUrl).with(rest());

if (token) {
return client.with(staticToken(token));
}

return client.with(authentication(“json”));
};

// Log in to get the access token
const client = directus();
const authData = await client.request(login(email, password));

login response:
{
expires: 900000,
access_token: ‘eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijg…I’
}

According to the docs Sdk | Directus Docs you need to add the json mode to the login instead of the authentication function.
Did you try that?

Hi. I have a similar question. It’s not clear how to re-use the token after authentication. My example is based on Vue JS. I have login (login.vue) page. I want to redirect the user to the Index page after login.

Here is my login.vue

So, I got an answer with only data expired value beacuse of cookie mode

{"data":{"expires":86400000}}

And now, on the index.vue I want to get information about current user.

index.vue

I used pastebin to share my pieces of code because the editor here is the most awkward message editor I’ve ever seen

On the new page I created directus again

const directus = createDirectus(‘hxxp://directus.local:8055’).with(rest());

And looks like it is not authorized automatically, so I got a 401 error.

Should I put the createDirecrus to the dedicated JS file and use it across the app? Or I need to create it on every page and put the token from Cookies somehow?

Does anybody have an example of using it in such use cases?