Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using CozyBrowser cookies' with request #825

Open
mikael-s opened this issue Dec 19, 2021 · 0 comments
Open

Using CozyBrowser cookies' with request #825

mikael-s opened this issue Dec 19, 2021 · 0 comments

Comments

@mikael-s
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant