SharesService.login not returning cookies

Hi. I’m unable to get the SharesService.login to work properly.

For example, based on this → directus/api/src/services/shares.ts at f55913653b02caa7cf8fbd90a0c2b48108419719 · directus/directus · GitHub, i’m trying the following:

handler: (router, context) => {

  const { services, getSchema, logger } = context;
  const { ItemsService, SharesService } = services;

  router.post('/create', async (req, res) => {

  try {
    const schema = await getSchema();                
    const s = new SharesService.login({schema});
    const result = await s.login({share: ‘<share_id>‘}, {session: true});
    
    return res.status(200).json(result);
  } catch(err) {
    logger?.error?.(err);
    return res.status(500);
  }

}

But instead of getting the directus_session_token in a cookie, i keep receiving just the result object in the Response body.

Why?

How to rectify this code?

Hi @Nik , thanks for your reply.

Regarding:

i assumed that if i went only with the built-in endpoints, i would also need to provide ‘Create Share’ permissions to the User (which i really would like to avoid).

Do correct me i’m wrong or missing something here! :slight_smile:

I just deleted my initial answer, because when i just tried to reproduce I could not gain access to a shared resource as I described. I’m not sure if I messed up something or if the gained access_token is limited to Directus Studio App. Anyway, i don’t want to confuse further by a possible wrong answer.

I will be back on this topic after the weekend in case no one else can provide a solution or clarification.