zapier / zapier-platform

The SDK for you to build an integration on Zapier

Home Page:https://platform.zapier.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to retrieve element of http response headers from response of a Token Exchange Request?

anupa1234 opened this issue · comments

commented

Current Behavior

I am using Session auth to integrate zapier with our app.
Our app response cookie as a http response header in a token exchange request. I would like to use cookie in sub sequent request. I tried to fetch it with z.console.log(response.headers['set-cookie']); but it always shows un-defined.
3

2

Desired Behavior

z.console.log(response.headers['set-cookie']); should return cookie that got from response.

Sorry for the late reply!

Does your app server redirect the request? If so, set-cookie isn't there probably because you're getting it from the redirected response. To stop z.request from redirecting, set redirect to manual:

const options = {
  url: '...',
  redirect: 'manual',
};
return z.request(options).then((response) => {
  const results = response.data;
  z.console.log(response.headers['set-cookie']);
  return results;
});

You can read more options in node-fetch's docs.

I'm closing this, but feel free to reopen if ☝️ doesn't fix it for you. Thanks!