slacktokengetter 0.1.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ dist/
2
+ *.egg-info/
3
+ __pycache__/
4
+ *.pyc
5
+ .venv/
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: slacktokengetter
3
+ Version: 0.1.9
4
+ Summary: Gets Slack tokens - wrapper around slacktokens providing a CLI entrypoint
5
+ License-Expression: MIT AND GPL-3.0-only
6
+ Requires-Python: <3.12,>=3.11
7
+ Requires-Dist: cryptography==43.*
8
+ Requires-Dist: keyring==25.*
9
+ Requires-Dist: leveldb==0.201
10
+ Description-Content-Type: text/markdown
11
+
12
+ # slacktokengetter
13
+ Gets Slack tokens — wrapper around [slacktokens](https://github.com/mickey/slacktokens) providing a CLI entrypoint.
14
+
15
+ ## Usage
16
+
17
+ ```
18
+ uvx slacktokengetter
19
+ ```
20
+
21
+ Prints Slack tokens and cookies as JSON on stdout.
22
+
23
+ ## Acknowledgements
24
+
25
+ This project vendors [pycookiecheat](https://github.com/n8henrie/pycookiecheat) (commit [`fe0d6896`](https://github.com/n8henrie/pycookiecheat/commit/fe0d6896eda7a5687460843102625fe2e3b6d485)) by Nathan Henrie, licensed under the MIT License. A copy of that license is included in this repository as [`vendor/pycookiecheat-LICENSE`](vendor/pycookiecheat-LICENSE) and in the distributed packages as `pycookiecheat-LICENSE`.
26
+
27
+ This project vendors [slacktokens](https://github.com/hraftery/slacktokens) (commit [`69d8760b`](https://github.com/hraftery/slacktokens/commit/69d8760b7dfbb8034a4548a2299368a46d4da663)) by Heath Raftery, licensed under the GNU General Public License v3 (GPLv3). A copy of that license is included in this repository as [`vendor/slacktokens-LICENSE`](vendor/slacktokens-LICENSE) and in the distributed packages as `slacktokens-LICENSE`.
@@ -0,0 +1,16 @@
1
+ # slacktokengetter
2
+ Gets Slack tokens — wrapper around [slacktokens](https://github.com/mickey/slacktokens) providing a CLI entrypoint.
3
+
4
+ ## Usage
5
+
6
+ ```
7
+ uvx slacktokengetter
8
+ ```
9
+
10
+ Prints Slack tokens and cookies as JSON on stdout.
11
+
12
+ ## Acknowledgements
13
+
14
+ This project vendors [pycookiecheat](https://github.com/n8henrie/pycookiecheat) (commit [`fe0d6896`](https://github.com/n8henrie/pycookiecheat/commit/fe0d6896eda7a5687460843102625fe2e3b6d485)) by Nathan Henrie, licensed under the MIT License. A copy of that license is included in this repository as [`vendor/pycookiecheat-LICENSE`](vendor/pycookiecheat-LICENSE) and in the distributed packages as `pycookiecheat-LICENSE`.
15
+
16
+ This project vendors [slacktokens](https://github.com/hraftery/slacktokens) (commit [`69d8760b`](https://github.com/hraftery/slacktokens/commit/69d8760b7dfbb8034a4548a2299368a46d4da663)) by Heath Raftery, licensed under the GNU General Public License v3 (GPLv3). A copy of that license is included in this repository as [`vendor/slacktokens-LICENSE`](vendor/slacktokens-LICENSE) and in the distributed packages as `slacktokens-LICENSE`.
@@ -0,0 +1,38 @@
1
+ [project]
2
+ name = "slacktokengetter"
3
+ version = "0.1.9"
4
+ description = "Gets Slack tokens - wrapper around slacktokens providing a CLI entrypoint"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11,<3.12"
7
+ license = "MIT AND GPL-3.0-only"
8
+ dependencies = [
9
+ "leveldb==0.201",
10
+ "cryptography==43.*",
11
+ "keyring==25.*",
12
+ ]
13
+
14
+ [project.scripts]
15
+ slacktokengetter = "slacktokengetter:main"
16
+
17
+ [build-system]
18
+ requires = ["hatchling"]
19
+ build-backend = "hatchling.build"
20
+
21
+ [tool.hatch.build.targets.wheel]
22
+ packages = ["src/slacktokengetter", "vendor/pycookiecheat/src/pycookiecheat"]
23
+
24
+ [tool.hatch.build.targets.wheel.force-include]
25
+ "vendor/pycookiecheat-LICENSE" = "pycookiecheat-LICENSE"
26
+ "vendor/slacktokens/slacktokens.py" = "slacktokens.py"
27
+ "vendor/slacktokens-LICENSE" = "slacktokens-LICENSE"
28
+
29
+ [tool.hatch.build.targets.sdist]
30
+ include = [
31
+ "src/",
32
+ "vendor/pycookiecheat/src/",
33
+ "vendor/pycookiecheat-LICENSE",
34
+ "vendor/slacktokens/slacktokens.py",
35
+ "vendor/slacktokens-LICENSE",
36
+ "pyproject.toml",
37
+ "README.md",
38
+ ]
@@ -0,0 +1,7 @@
1
+ import json
2
+
3
+ import slacktokens
4
+
5
+
6
+ def main():
7
+ print(json.dumps(slacktokens.get_tokens_and_cookie()))
@@ -0,0 +1,141 @@
1
+ # pycookiecheat
2
+
3
+ [![master branch build
4
+ status](https://github.com/n8henrie/pycookiecheat/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/n8henrie/pycookiecheat/actions/workflows/python-package.yml)
5
+
6
+ Borrow cookies from your browser's authenticated session for use in Python
7
+ scripts.
8
+
9
+ - Free software: MIT
10
+ - [Documentation](https://n8henrie.com/2013/11/use-chromes-cookies-for-easier-downloading-with-python-requests/)
11
+
12
+ ## Installation
13
+
14
+ **NB:** Use `pip` and `python` instead of `pip3` and `python3` if you're still
15
+ on Python 2 and using pycookiecheat < v0.4.0. pycookiecheat >= v0.4.0 requires
16
+ Python 3 and in general will aim to support python versions that are stable and
17
+ not yet end-of-life: <https://devguide.python.org/versions>.
18
+
19
+ - `python3 -m pip install pycookiecheat`
20
+
21
+ ### Installation notes regarding alternative keyrings on Linux
22
+
23
+ See [#12](https://github.com/n8henrie/pycookiecheat/issues/12). Chrome is now
24
+ using a few different keyrings to store your `Chrome Safe Storage` password,
25
+ instead of a hard-coded password. Pycookiecheat doesn't work with most of these
26
+ so far, and to be honest my enthusiasm for adding support for ones I don't use
27
+ is limited. However, users have contributed code that seems to work with some
28
+ of the recent Ubuntu desktops. To get it working, you may have to `sudo apt-get
29
+ install libsecret-1-dev python-gi python3-gi`, and if you're installing into a
30
+ virtualenv (highly recommended), you need to use the `--system-site-packages`
31
+ flag to get access to the necessary libraries.
32
+
33
+ Alternatively, some users have suggested running Chrome with the
34
+ `--password-store=basic` or `--use-mock-keychain` flags.
35
+
36
+ ### Development Setup
37
+
38
+ 1. `git clone https://github.com/n8henrie/pycookiecheat.git`
39
+ 1. `cd pycookiecheat`
40
+ 1. `python3 -m venv .venv`
41
+ 1. `./.venv/bin/python -m pip install -e .[dev]`
42
+
43
+ ## Usage
44
+
45
+ ### As a Command-Line Tool
46
+
47
+ After installation, the CLI tool can be run as a python module `python -m` or
48
+ with a standalone console script:
49
+
50
+ ```console
51
+ $ python -m pycookiecheat --help
52
+ usage: pycookiecheat [-h] [-b BROWSER] [-o OUTPUT_FILE] [-v] [-c COOKIE_FILE]
53
+ [-V]
54
+ url
55
+
56
+ Copy cookies from Chrome or Firefox and output as json
57
+
58
+ positional arguments:
59
+ url
60
+
61
+ options:
62
+ -h, --help show this help message and exit
63
+ -b BROWSER, --browser BROWSER
64
+ -o OUTPUT_FILE, --output-file OUTPUT_FILE
65
+ Output to this file in netscape cookie file format
66
+ -v, --verbose Increase logging verbosity (may repeat), default is
67
+ `logging.ERROR`
68
+ -c COOKIE_FILE, --cookie-file COOKIE_FILE
69
+ Cookie file
70
+ -V, --version show program's version number and exit
71
+
72
+ ```
73
+
74
+ By default it prints the cookies to stdout as JSON but can also output a file in
75
+ Netscape Cookie File Format.
76
+
77
+ ### As a Python Library
78
+
79
+ ```python
80
+ from pycookiecheat import BrowserType, get_cookies
81
+ import requests
82
+
83
+ url = 'https://n8henrie.com'
84
+
85
+ # Uses Chrome's default cookies filepath by default
86
+ cookies = get_cookies(url)
87
+ r = requests.get(url, cookies=cookies)
88
+
89
+ # Using an alternate browser
90
+ cookies = get_cookies(url, browser=BrowserType.CHROMIUM)
91
+ ```
92
+
93
+ Use the `cookie_file` keyword-argument to specify a different path to the file
94
+ containing your cookies:
95
+ `get_cookies(url, cookie_file='/abspath/to/cookies')`
96
+
97
+ You may be able to retrieve cookies for alternative Chromium-based browsers by
98
+ manually specifying something like
99
+ `"/home/username/.config/BrowserName/Default/Cookies"` as your `cookie_file`.
100
+
101
+ ## Features
102
+
103
+ - Returns decrypted cookies from Google Chrome, Brave, or Slack, on MacOS or
104
+ Linux.
105
+ - Optionally outputs cookies to file (thanks to Muntashir Al-Islam!)
106
+
107
+ ## FAQ / Troubleshooting
108
+
109
+ ### How about Windows?
110
+
111
+ I don't use Windows or have a PC, so I won't be adding support myself. Feel
112
+ free to make a PR :)
113
+
114
+ ### I get an installation error with the `cryptography` module on OS X
115
+ (pycookiecheat <v0.4.0)
116
+
117
+ If you're getting [this
118
+ error](https://github.com/n8henrie/pycookiecheat/pull/11#issuecomment-221918807)
119
+ and using Homebrew, then you need to follow the instructions for [Building
120
+ cryptography on OS
121
+ X](https://cryptography.io/en/latest/installation/?highlight=cflags#building-cryptography-on-os-x)
122
+ and `export LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix
123
+ openssl)/include"` and try again.
124
+
125
+ ### I get an installation error with the `cryptography` module on Linux
126
+
127
+ Please check the official cryptography docs. On some systems (e.g. Ubuntu), you
128
+ may need to do something like `sudo apt-get install build-essential libssl-dev
129
+ libffi-dev python-dev` prior to installing with `pip`.
130
+
131
+ ### How can I use pycookiecheat on KDE-based Linux distros?
132
+
133
+ On KDE, Chrome defaults to using KDE's own keyring, KWallet. For pycookiecheat to support KWallet the [`dbus-python`](https://pypi.org/project/dbus-python/) package must be installed.
134
+
135
+ ### How do I install the (unreleased) master branch with pip?
136
+
137
+ - `python -m pip install git+https://github.com/n8henrie/pycookiecheat@master`
138
+
139
+ ## Buy Me a Coffee
140
+
141
+ [☕️](https://n8henrie.com/donate)
@@ -0,0 +1,67 @@
1
+ [build-system]
2
+ requires = ["setuptools>65", "setuptools_scm[toml]>=7"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.setuptools]
6
+ zip-safe = false
7
+
8
+ [tool.setuptools.dynamic]
9
+ version = {attr = "pycookiecheat.__version__"}
10
+ readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"}
11
+
12
+ [tool.mypy]
13
+ check_untyped_defs = true
14
+ disallow_untyped_calls = true
15
+ disallow_untyped_defs = true
16
+ follow_imports = "silent"
17
+ ignore_missing_imports = true
18
+ python_version = "3.9"
19
+ show_column_numbers = true
20
+ warn_incomplete_stub = false
21
+ warn_redundant_casts = true
22
+ warn_unused_ignores = true
23
+
24
+ [tool.ruff]
25
+ line-length = 79
26
+
27
+ [tool.ruff.lint]
28
+ select = ["I", "E4", "E7", "E9", "F"]
29
+
30
+ [project]
31
+ name = "pycookiecheat"
32
+ urls = {homepage = "https://github.com/n8henrie/pycookiecheat"}
33
+ dynamic = ["version", "readme"]
34
+ license = { text = "MIT" }
35
+ description = "Borrow cookies from your browser's authenticated session for use in Python scripts."
36
+ authors = [ {name = "Nathan Henrie", email = "nate@n8henrie.com"} ]
37
+ keywords = ["pycookiecheat", "chrome", "chromium cookies", "cookies", "firefox"]
38
+ classifiers= [
39
+ "Natural Language :: English",
40
+ "Programming Language :: Python :: 3",
41
+ "Programming Language :: Python :: 3.9",
42
+ "Programming Language :: Python :: 3.10",
43
+ "Programming Language :: Python :: 3.11",
44
+ "Programming Language :: Python :: 3.12",
45
+ "Programming Language :: Python :: 3.13",
46
+ ]
47
+ dependencies = [
48
+ "cryptography==43.*",
49
+ "keyring==25.*",
50
+ ]
51
+
52
+ [project.optional-dependencies]
53
+ test = [
54
+ "mypy==1.*",
55
+ "playwright==1.*",
56
+ "pytest==8.*",
57
+ "ruff==0.7.*",
58
+ "tox==4.*",
59
+ ]
60
+ dev = [
61
+ "build==1.*",
62
+ "twine==5.*",
63
+ "wheel==0.43.*",
64
+ ]
65
+
66
+ [project.scripts]
67
+ pycookiecheat = "pycookiecheat.__main__:main"
@@ -0,0 +1,16 @@
1
+ """__init__.py :: Exposes chrome_cookies function."""
2
+
3
+ from pycookiecheat.chrome import chrome_cookies
4
+ from pycookiecheat.common import BrowserType, get_cookies
5
+ from pycookiecheat.firefox import firefox_cookies
6
+
7
+ __author__ = "Nathan Henrie"
8
+ __email__ = "nate@n8henrie.com"
9
+ __version__ = "v0.8.0"
10
+
11
+ __all__ = [
12
+ "BrowserType",
13
+ "chrome_cookies",
14
+ "firefox_cookies",
15
+ "get_cookies",
16
+ ]
@@ -0,0 +1,70 @@
1
+ """Provide a command-line tool for pycookiecheat."""
2
+
3
+ import argparse
4
+ import json
5
+ import logging
6
+ from importlib.metadata import version
7
+
8
+ from .common import BrowserType, get_cookies
9
+
10
+
11
+ def _cli() -> argparse.ArgumentParser:
12
+ parser = argparse.ArgumentParser(
13
+ prog="pycookiecheat",
14
+ description="Copy cookies from Chrome or Firefox and output as json",
15
+ )
16
+ parser.add_argument("url")
17
+ parser.add_argument(
18
+ "-b", "--browser", type=BrowserType, default=BrowserType.CHROME
19
+ )
20
+ parser.add_argument(
21
+ "-o",
22
+ "--output-file",
23
+ help="Output to this file in netscape cookie file format",
24
+ )
25
+ parser.add_argument(
26
+ "-v",
27
+ "--verbose",
28
+ action="count",
29
+ default=0,
30
+ help=(
31
+ "Increase logging verbosity (may repeat), default is "
32
+ "`logging.ERROR`"
33
+ ),
34
+ )
35
+ parser.add_argument(
36
+ "-c",
37
+ "--cookie-file",
38
+ help="Cookie file",
39
+ )
40
+ parser.add_argument(
41
+ "-V",
42
+ "--version",
43
+ action="version",
44
+ version=version(parser.prog),
45
+ )
46
+ return parser
47
+
48
+
49
+ def main() -> None:
50
+ """Provide a main entrypoint for the command-line tool."""
51
+ parser = _cli()
52
+ args = parser.parse_args()
53
+
54
+ logging.basicConfig(level=max(logging.ERROR - 10 * args.verbose, 0))
55
+
56
+ # todo: make this a match statement once MSPV is 3.10
57
+ browser = BrowserType(args.browser)
58
+
59
+ cookies = get_cookies(
60
+ url=args.url,
61
+ browser=browser,
62
+ curl_cookie_file=args.output_file,
63
+ cookie_file=args.cookie_file,
64
+ )
65
+ if not args.output_file:
66
+ print(json.dumps(cookies, indent=4))
67
+
68
+
69
+ if __name__ == "__main__":
70
+ main()