Skip to content

Using CozyBrowser cookies' with request #825

@mikael-s

Description

@mikael-s

Hi!

I'm currently trying to use CozyBrowser to parse a website, retrieve its cookies and reuse them with request (for saveFiles). For that purpose I followed the documentation. However I've not succeeded to make it work.

Here is a "small" example, where I connect to a website using CozyBrowser and then, I try to reuse CozyBrowser's cookies to perform a request on the landing page:

const {
  BaseKonnector,
  requestFactory,
  log
} = require('cozy-konnector-libs')
const CozyBrowser = require('cozy-konnector-libs/dist/libs/CozyBrowser')
const browser = new CozyBrowser()

module.exports = new BaseKonnector(fetch)

async function fetch(fields) {
    await browser.visit('http://testphp.vulnweb.com/login.php');
    browser.fill('uname', 'test');
    browser.fill('pass', 'test');
    await browser.pressButton("login");
    log('info', 'location: '+browser.location.pathname)

    
    const j = browser.getCookieJar()
    const request_jar = requestFactory({
        debug: true,
        jar: j
    })

    const res = await request_jar('http://testphp.vulnweb.com/userinfo.php');
}

However the request fails with the error message BaseKonnector: critical : Cannot read property 'secure' of undefined. I'm using cozy-konnector-libs v.4.42.2.

Is there a workaround to make this work?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions