Page.GetCookiesAsync does not return all the cookies
The method Page.GetCookiesAsync() doesn't return all the cookies showed in the Chrome Dev Tools. After googling this issue, i found a nice explanation on Stack Overflow (https://stackoverflow.com/questions/49389775/puppeteers-page-cookies-not-retrieving-all-cookies-shown-in-the-chrome-dev-to/59604510). So basically the cookie i want is probably an httpOnly cookie, wich is not retrieved by the "Network.getCookies" command performed by the Page.GetCookiesAsync() method.
My humble suggestion would be adding an method called Page.GetAllCookiesAsync(), with this implementation:
public async Task<CookieParam[]> GetAllCookiesAsync(params string[] urls) => (await Client.SendAsync<NetworkGetCookiesResponse>("Network.getAllCookies", new NetworkGetCookiesRequest { Urls = urls.Length > 0 ? urls : new string[] { Url } }).ConfigureAwait(false)).Cookies;
In other words, just a clone of the already existing Page.GetCookiesAsync() method, but with the "Network.getAllCookies" call instead of the "Network.getCookies".
Thank you for the insight and the time to go through it. I think that makes sense. I would like to implement that on the original puppeteer library so we are in sync. We shouldn't have any API that doesn't match an upstream one.
Thank you for the insight and the time to go through it. I think that makes sense. I would like to implement that on the original puppeteer library so we are in sync. We shouldn't have any API that doesn't match an upstream one.
Thanks for the feedback! Meanwhile, I found a workaround. Since the Page.GetCookiesAsync() accepts an array of urls as optional parameter, I've just inspected and passed all the urls of the cookies I needed.
It depends on https://github.com/puppeteer/puppeteer/issues/6916