1

Sometimes is hard to do just simple stuff with puppeteer. I was wondering if it is possible to use puppeteer to login to a dropbox link with password and then use someting like wget or curl to do the rest. I imagine that I would need to read and then pass on on some sort of access token after the login.

Would this be possible?

(yes, I know that using the dropbox API would perhaps be an easier and more correct solution)

B--rian
  • 5,578
  • 10
  • 38
  • 89
Norfeldt
  • 8,272
  • 23
  • 96
  • 152
  • If you know where or in which format the token is stored, local/session storage, cookie secure or normal, then may be you can use curl or wget and pass the token with it. But like you said dropbox api will be an easier way – karthick May 28 '20 at 18:27
  • No I don't.. Is there an easy way to figure it out? – Norfeldt May 28 '20 at 18:27
  • I created an account and tried clearing local and session storage , and refreshed the page, I am still authorized so it should be one of the cookies. I don't think there is an easy way, look for larger values in secure cookies and try removing them and refresh the page, if you are authorized then that's not the right cookie. – karthick May 28 '20 at 18:36
  • @karthick thank you very much for taking the time to help me out. Do you know how to get/read the cookie in puppeteer? – Norfeldt May 28 '20 at 19:05
  • to read normal cookies just call the cookies method in the page object page.cookies() , but that wont include http cookies. So you need to use Chrome devtools protocol, search for CDP network cookies, you should get some resources – karthick May 28 '20 at 19:34
  • You can store the cookies and reuse them. Here is the original [answer](https://stackoverflow.com/a/56515357/6189678) – vadimk7 May 29 '20 at 13:18

1 Answers1

1

I am not familiar how puppeteer stores cookies, but I am sure you can do that, see references below, and e.g. the Puppeteer API docu on cookies.

Here my 50 cents on wget and/or cURL with access control. In both cases it is possible to load cookies which provide you access to dropbox. Assume you have them stored in myAccessCookies.txt, you can reload them and use them e.g. with wget:

wget -qO- --load-cookies myAccessCookies.txt http://www.example.com/replaceWithDropboxLink

Another hint: To my knowledge, Dropbox allows to share direct, temporary links to files which do not require further authentication, see e.g. https://help.dropbox.com/files-folders/share/set-link-permissions - if this is not a security threat, and you can influence your counter-party to use these, everything is easy.

References and further reading

B--rian
  • 5,578
  • 10
  • 38
  • 89