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

Sending Authentication/token Info #142

Closed
vaibhav15s opened this issue Apr 9, 2018 · 2 comments
Closed

Sending Authentication/token Info #142

vaibhav15s opened this issue Apr 9, 2018 · 2 comments

Comments

@vaibhav15s
Copy link

Hi
Is there a way I can send token information or basic authentication?

@olecom
Copy link

olecom commented Apr 11, 2018

basic authentication

@vaibhav15s, I guess you can take needed page directly via 'chrome-remote-interface'

const {Network, Page, Runtime} = client;
await throwIfCanceledOrFailed(options);
if (options.clearCache) {
await Network.clearBrowserCache();
}
// Enable events to be used here, in generate(), or in afterNavigate().
await Promise.all([
Network.enable(),
Page.enable(),
Runtime.enable(),
]);

Try to place https://chromedevtools.github.io/devtools-protocol/tot/Network#method-setExtraHTTPHeaders
somewhere after client.Network.enable(), in example below:

async function htmlTune(html){
    // get HTML into Chrome to get computed style via `runtimeConsoleHandler`
    var options = {
        port: 9222,
        runtimeConsoleHandler: getTemplateImageDimentions
    }
    // https://chromedevtools.github.io/devtools-protocol/tot/
    var tab = await CDP.New(options)
    var client = await CDP(Object.assign({}, options, { target: tab }))

    // Enable events to be used here
    await Promise.all([
        client.Network.clearBrowserCache(),
        client.Network.enable(),
        client.Page.enable(),
        client.Runtime.enable(),
    ]);
    if (options.runtimeConsoleHandler) {
        client.Runtime.consoleAPICalled(options.runtimeConsoleHandler)
    }

    const { frameTree } = await client.Page.getResourceTree()
    // open HTML and get info via `runtimeConsoleHandler`
    await client.Page.setDocumentContent({ html, frameId: frameTree.frame.id })
    await client.Page.loadEventFired()
    await CDP.Close(Object.assign(options, { id: tab.id }))
}

rgba pushed a commit to rgba/html-pdf-chrome that referenced this issue Jul 9, 2019
- fixes Sending Authentication/token Info westy92#142
- fixes Add extra http header westy92#198
@westy92
Copy link
Owner

westy92 commented Jul 19, 2019

I just published v0.6.0 which now supports sending custom HTTP headers with a request!
https://github.com/westy92/html-pdf-chrome#http-headers

@westy92 westy92 closed this as completed Jul 19, 2019
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

3 participants