Closed hraftery closed 1 year ago
Interesting find!
Yes, can you please make this into a PR?
Any chance you can also incorporate a test or two?
@hraftery Are you interested in making a pull request? Otherwise I'll likely close this soonish.
I am yes. Went travelling immediately after your message and haven’t returned to it, but intend to do so.
Sent from my iPad
On 16 Jul 2022, at 3:28 am, Nathan Henrie @.***> wrote:
@hraftery Are you interested in making a pull request? Otherwise I'll likely close this soonish.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.
Sweet, thanks. Enjoy your travels!
macOS 11.6.5 and Linux Mint 20
3.9.12 and 3.8.10
v0.4.7 and master head.
My Issue
The Slack desktop app uses the same cookie storage mechanism as Chrome and Chromium, and there appears to be no more advanced tool for Cookie extraction than
pycookiecheat
. Although the use cases for extracting cookies from a browser (ie. to browse web pages) might be slightly different to the use cases for extracting cookies from Slack (ie. to access the Slack API manually), the modification to allowpycookiecheat
to do both turns out to be really small.After much consideration about whether to diverge or merge, I believe the best option is to generalise
pycookiecheat
's functionality slightly, and keep it as the best resource for cookie extraction.WHYT
Simply passing "Slack" as the
browser
parameter and Slack's cookie file as thecookie_file
parameter tochrome_cookies()
results in the misleading "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 3: invalid start byte" type errors. It turns out this is simply because the wrong password is pulled from the keyring. All that needs to change for this to work is to point to a different keyring. Specifying the correctcookie_file
can easily be achieved using the existing interface, but specifying the keyring name cannot.By simply allowing "Slack" as a browser name, the keyring name is correctly determined on macos. The story is a bit more complicated on Linux (tested with some effort on Linux Mint), but turns out to provide a more robust keyring determination method in general anyway.
Thus, I'd like to offer the improvements in a pull request, in the hope that they find their way to PyPI. The relevant commit is
here.Please make sure you've taken these steps before submitting a new issue: