Sync cookies from the browser and use them in a script

I want to test my graphql API. And it requires an access token. Normally I just run the front-end in local and take the access token from a request header and paste it inside postman.

Then I found Postman allows to sync and capture cookies: Sync cookies using Postman Interceptor and the Postman proxy | Postman Learning Center

My idea was to create a script in the healtcheck to write the captured cookie in and env vars so that all of the other endpoints can work.

But following the docs: Create and capture cookies using Postman's cookie manager | Postman Learning Center

When I used const cookieJar = pm.cookies.jar(); I got an error because cookies was undefined. I couldn’t find any documentation about this issue.

I use a Mac with Apple silicon. With Postman Version 11.0.5. A Graphql API. With local domains (ex. dev.localhost)

Any idea what it could be? Or any troubleshooting suggestions?

Hi @alexanderfanz. Welcome to the Postman Community.

I’m trying to understand your workflow and use case. It appears to me like using the interceptor or Proxy might not be the most ideal way to achieve your use case.

Is there an authentication or authorization request that the frontend makes to generate this access token that you used to copy and paste initially? You can make that request in Postman, and store the access token a collection or environment variable. This ensures that your requests always has access to this variable (the access token) when it needs it. You can run this Auth request to get a valid variable each time, or use the collection runner to automate this flow.