amazon-auth 0.0.2__tar.gz → 0.1.0__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.
- amazon_auth-0.1.0/PKG-INFO +126 -0
- amazon_auth-0.1.0/README.md +58 -0
- amazon_auth-0.1.0/amazon_auth.egg-info/PKG-INFO +126 -0
- amazon_auth-0.1.0/amazon_auth.egg-info/SOURCES.txt +34 -0
- amazon_auth-0.1.0/amazon_auth.egg-info/entry_points.txt +2 -0
- amazon_auth-0.1.0/amazon_auth.egg-info/requires.txt +48 -0
- {amazon_auth-0.0.2 → amazon_auth-0.1.0}/amazonauth/__init__.py +2 -1
- amazon_auth-0.1.0/amazonauth/cli.py +262 -0
- amazon_auth-0.1.0/amazonauth/conf.py +327 -0
- amazon_auth-0.1.0/amazonauth/constants.py +256 -0
- amazon_auth-0.1.0/amazonauth/contrib/__init__.py +0 -0
- amazon_auth-0.1.0/amazonauth/contrib/browser/__init__.py +0 -0
- amazon_auth-0.1.0/amazonauth/contrib/browser/playwright.py +990 -0
- amazon_auth-0.1.0/amazonauth/contrib/waf/__init__.py +0 -0
- amazon_auth-0.1.0/amazonauth/contrib/waf/anticaptcha.py +69 -0
- amazon_auth-0.1.0/amazonauth/contrib/waf/base.py +164 -0
- amazon_auth-0.1.0/amazonauth/contrib/waf/capsolver.py +122 -0
- amazon_auth-0.1.0/amazonauth/contrib/waf/twocaptcha.py +71 -0
- amazon_auth-0.1.0/amazonauth/exception.py +50 -0
- amazon_auth-0.1.0/amazonauth/forms.py +601 -0
- amazon_auth-0.1.0/amazonauth/py.typed +0 -0
- amazon_auth-0.1.0/amazonauth/region_data.py +162 -0
- amazon_auth-0.1.0/amazonauth/selectors.py +101 -0
- amazon_auth-0.1.0/amazonauth/session.py +579 -0
- amazon_auth-0.1.0/amazonauth/util.py +146 -0
- amazon_auth-0.1.0/pyproject.toml +167 -0
- amazon_auth-0.1.0/tests/test_cli.py +276 -0
- amazon_auth-0.1.0/tests/test_conf.py +301 -0
- amazon_auth-0.1.0/tests/test_constants.py +234 -0
- amazon_auth-0.1.0/tests/test_package.py +19 -0
- amazon_auth-0.1.0/tests/test_session.py +1548 -0
- amazon_auth-0.1.0/tests/test_util.py +130 -0
- amazon_auth-0.0.2/PKG-INFO +0 -30
- amazon_auth-0.0.2/README.md +0 -11
- amazon_auth-0.0.2/amazon_auth.egg-info/PKG-INFO +0 -30
- amazon_auth-0.0.2/amazon_auth.egg-info/SOURCES.txt +0 -8
- amazon_auth-0.0.2/pyproject.toml +0 -30
- {amazon_auth-0.0.2 → amazon_auth-0.1.0}/LICENSE +0 -0
- {amazon_auth-0.0.2 → amazon_auth-0.1.0}/amazon_auth.egg-info/dependency_links.txt +0 -0
- {amazon_auth-0.0.2 → amazon_auth-0.1.0}/amazon_auth.egg-info/top_level.txt +0 -0
- {amazon_auth-0.0.2 → amazon_auth-0.1.0}/setup.cfg +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amazon-auth
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Sign in to Amazon's consumer website and reuse the session from Python.
|
|
5
|
+
Author-email: Alex Laird <contact@alexlaird.com>
|
|
6
|
+
Maintainer-email: Alex Laird <contact@alexlaird.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Changelog, https://github.com/alexdlaird/amazon-auth/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Sponsor, https://github.com/sponsors/alexdlaird
|
|
10
|
+
Project-URL: Source Code, https://github.com/alexdlaird/amazon-auth
|
|
11
|
+
Keywords: amazon,auth,sign-in,session
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: click>=7.1
|
|
28
|
+
Requires-Dist: requests>=2.23
|
|
29
|
+
Requires-Dist: beautifulsoup4>=4.14
|
|
30
|
+
Requires-Dist: PyYAML>=6.0.3
|
|
31
|
+
Requires-Dist: Pillow>=9.0.1
|
|
32
|
+
Requires-Dist: pyotp>=2.9
|
|
33
|
+
Provides-Extra: browser
|
|
34
|
+
Requires-Dist: playwright>=1.47.0; extra == "browser"
|
|
35
|
+
Provides-Extra: capsolver
|
|
36
|
+
Requires-Dist: capsolver; extra == "capsolver"
|
|
37
|
+
Provides-Extra: anticaptcha
|
|
38
|
+
Requires-Dist: anticaptchaofficial; extra == "anticaptcha"
|
|
39
|
+
Provides-Extra: 2captcha
|
|
40
|
+
Requires-Dist: 2captcha-python; extra == "2captcha"
|
|
41
|
+
Provides-Extra: lxml
|
|
42
|
+
Requires-Dist: lxml; extra == "lxml"
|
|
43
|
+
Provides-Extra: captcha
|
|
44
|
+
Requires-Dist: amazoncaptcha>=0.4; extra == "captcha"
|
|
45
|
+
Provides-Extra: docs
|
|
46
|
+
Requires-Dist: Sphinx; extra == "docs"
|
|
47
|
+
Requires-Dist: sphinx-notfound-page; extra == "docs"
|
|
48
|
+
Requires-Dist: sphinx_autodoc_typehints; extra == "docs"
|
|
49
|
+
Requires-Dist: mypy; extra == "docs"
|
|
50
|
+
Requires-Dist: types-requests; extra == "docs"
|
|
51
|
+
Requires-Dist: types-Pillow; extra == "docs"
|
|
52
|
+
Requires-Dist: types-PyYAML; extra == "docs"
|
|
53
|
+
Requires-Dist: sphinx-sitemap; extra == "docs"
|
|
54
|
+
Requires-Dist: sphinxext-opengraph; extra == "docs"
|
|
55
|
+
Requires-Dist: furo; extra == "docs"
|
|
56
|
+
Provides-Extra: dev
|
|
57
|
+
Requires-Dist: pytest; extra == "dev"
|
|
58
|
+
Requires-Dist: coverage[toml]; extra == "dev"
|
|
59
|
+
Requires-Dist: flake8; extra == "dev"
|
|
60
|
+
Requires-Dist: flake8-pyproject; extra == "dev"
|
|
61
|
+
Requires-Dist: pep8-naming; extra == "dev"
|
|
62
|
+
Requires-Dist: mypy; extra == "dev"
|
|
63
|
+
Requires-Dist: types-requests; extra == "dev"
|
|
64
|
+
Requires-Dist: types-PyYAML; extra == "dev"
|
|
65
|
+
Requires-Dist: types-Pillow; extra == "dev"
|
|
66
|
+
Requires-Dist: responses; extra == "dev"
|
|
67
|
+
Dynamic: license-file
|
|
68
|
+
|
|
69
|
+
# amazon-auth
|
|
70
|
+
|
|
71
|
+
[](https://pypi.org/project/amazon-auth)
|
|
72
|
+
[](https://pypi.org/project/amazon-auth)
|
|
73
|
+
[](https://codecov.io/gh/alexdlaird/amazon-auth)
|
|
74
|
+
[](https://github.com/alexdlaird/amazon-auth/actions/workflows/build.yml)
|
|
75
|
+
[](https://amazon-auth.readthedocs.io)
|
|
76
|
+
[](https://github.com/alexdlaird/amazon-auth/blob/main/LICENSE)
|
|
77
|
+
|
|
78
|
+
`amazon-auth` is an unofficial library that signs in to Amazon's consumer website (amazon.com and other Amazon sites)
|
|
79
|
+
and persists the session, so it can be reused from Python or the command line. It handles sign-in, OTP and MFA,
|
|
80
|
+
challenges, and browser sign-in. [`amazon-orders`](https://github.com/alexdlaird/amazon-orders) is built on it.
|
|
81
|
+
|
|
82
|
+
> **Note:** This package works by parsing Amazon's consumer-facing website. As Amazon provides no official API to use,
|
|
83
|
+
> older versions of this package may break at any time, so it's recommended that you use the latest version.
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
`amazon-auth` is available on [PyPI](https://pypi.org/project/amazon-auth/) and can be installed and/or upgraded using `pip`:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
pip install amazon-auth --upgrade
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
That's it! `amazon-auth` is now available as a package to your Python projects and from the command line.
|
|
94
|
+
|
|
95
|
+
If pinning, be sure to use a wildcard for the [minor version](https://semver.org/) (e.g. `==0.1.*`, not `==0.1.0`) to
|
|
96
|
+
ensure you always get the latest stable release.
|
|
97
|
+
|
|
98
|
+
## Basic Usage
|
|
99
|
+
|
|
100
|
+
You'll use [`AmazonSession`](https://amazon-auth.readthedocs.io/api.html#amazonauth.session.AmazonSession) to sign in
|
|
101
|
+
to your Amazon account, then make requests with the signed-in session:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from amazonauth.session import AmazonSession
|
|
105
|
+
|
|
106
|
+
amazon_session = AmazonSession("<AMAZON_EMAIL>",
|
|
107
|
+
"<AMAZON_PASSWORD>")
|
|
108
|
+
amazon_session.login()
|
|
109
|
+
|
|
110
|
+
response = amazon_session.get("https://www.amazon.com/gp/css/homepage.html")
|
|
111
|
+
print(response.parsed.title.text)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The most secure way to sign in is on Amazon's own page, in a browser window, so your credentials never need to be
|
|
115
|
+
stored (this requires the `browser` extra, `pip install amazon-auth[browser]`):
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
amazon-auth login --browser
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The session is persisted, so `AmazonSession().login()` reuses it without credentials.
|
|
122
|
+
|
|
123
|
+
## Documentation
|
|
124
|
+
|
|
125
|
+
For more advanced usage, `amazon-auth`'s official documentation is available
|
|
126
|
+
at [Read the Docs](https://amazon-auth.readthedocs.io).
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# amazon-auth
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/amazon-auth)
|
|
4
|
+
[](https://pypi.org/project/amazon-auth)
|
|
5
|
+
[](https://codecov.io/gh/alexdlaird/amazon-auth)
|
|
6
|
+
[](https://github.com/alexdlaird/amazon-auth/actions/workflows/build.yml)
|
|
7
|
+
[](https://amazon-auth.readthedocs.io)
|
|
8
|
+
[](https://github.com/alexdlaird/amazon-auth/blob/main/LICENSE)
|
|
9
|
+
|
|
10
|
+
`amazon-auth` is an unofficial library that signs in to Amazon's consumer website (amazon.com and other Amazon sites)
|
|
11
|
+
and persists the session, so it can be reused from Python or the command line. It handles sign-in, OTP and MFA,
|
|
12
|
+
challenges, and browser sign-in. [`amazon-orders`](https://github.com/alexdlaird/amazon-orders) is built on it.
|
|
13
|
+
|
|
14
|
+
> **Note:** This package works by parsing Amazon's consumer-facing website. As Amazon provides no official API to use,
|
|
15
|
+
> older versions of this package may break at any time, so it's recommended that you use the latest version.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
`amazon-auth` is available on [PyPI](https://pypi.org/project/amazon-auth/) and can be installed and/or upgraded using `pip`:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pip install amazon-auth --upgrade
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
That's it! `amazon-auth` is now available as a package to your Python projects and from the command line.
|
|
26
|
+
|
|
27
|
+
If pinning, be sure to use a wildcard for the [minor version](https://semver.org/) (e.g. `==0.1.*`, not `==0.1.0`) to
|
|
28
|
+
ensure you always get the latest stable release.
|
|
29
|
+
|
|
30
|
+
## Basic Usage
|
|
31
|
+
|
|
32
|
+
You'll use [`AmazonSession`](https://amazon-auth.readthedocs.io/api.html#amazonauth.session.AmazonSession) to sign in
|
|
33
|
+
to your Amazon account, then make requests with the signed-in session:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from amazonauth.session import AmazonSession
|
|
37
|
+
|
|
38
|
+
amazon_session = AmazonSession("<AMAZON_EMAIL>",
|
|
39
|
+
"<AMAZON_PASSWORD>")
|
|
40
|
+
amazon_session.login()
|
|
41
|
+
|
|
42
|
+
response = amazon_session.get("https://www.amazon.com/gp/css/homepage.html")
|
|
43
|
+
print(response.parsed.title.text)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The most secure way to sign in is on Amazon's own page, in a browser window, so your credentials never need to be
|
|
47
|
+
stored (this requires the `browser` extra, `pip install amazon-auth[browser]`):
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
amazon-auth login --browser
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The session is persisted, so `AmazonSession().login()` reuses it without credentials.
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
For more advanced usage, `amazon-auth`'s official documentation is available
|
|
58
|
+
at [Read the Docs](https://amazon-auth.readthedocs.io).
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amazon-auth
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Sign in to Amazon's consumer website and reuse the session from Python.
|
|
5
|
+
Author-email: Alex Laird <contact@alexlaird.com>
|
|
6
|
+
Maintainer-email: Alex Laird <contact@alexlaird.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Changelog, https://github.com/alexdlaird/amazon-auth/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Sponsor, https://github.com/sponsors/alexdlaird
|
|
10
|
+
Project-URL: Source Code, https://github.com/alexdlaird/amazon-auth
|
|
11
|
+
Keywords: amazon,auth,sign-in,session
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: click>=7.1
|
|
28
|
+
Requires-Dist: requests>=2.23
|
|
29
|
+
Requires-Dist: beautifulsoup4>=4.14
|
|
30
|
+
Requires-Dist: PyYAML>=6.0.3
|
|
31
|
+
Requires-Dist: Pillow>=9.0.1
|
|
32
|
+
Requires-Dist: pyotp>=2.9
|
|
33
|
+
Provides-Extra: browser
|
|
34
|
+
Requires-Dist: playwright>=1.47.0; extra == "browser"
|
|
35
|
+
Provides-Extra: capsolver
|
|
36
|
+
Requires-Dist: capsolver; extra == "capsolver"
|
|
37
|
+
Provides-Extra: anticaptcha
|
|
38
|
+
Requires-Dist: anticaptchaofficial; extra == "anticaptcha"
|
|
39
|
+
Provides-Extra: 2captcha
|
|
40
|
+
Requires-Dist: 2captcha-python; extra == "2captcha"
|
|
41
|
+
Provides-Extra: lxml
|
|
42
|
+
Requires-Dist: lxml; extra == "lxml"
|
|
43
|
+
Provides-Extra: captcha
|
|
44
|
+
Requires-Dist: amazoncaptcha>=0.4; extra == "captcha"
|
|
45
|
+
Provides-Extra: docs
|
|
46
|
+
Requires-Dist: Sphinx; extra == "docs"
|
|
47
|
+
Requires-Dist: sphinx-notfound-page; extra == "docs"
|
|
48
|
+
Requires-Dist: sphinx_autodoc_typehints; extra == "docs"
|
|
49
|
+
Requires-Dist: mypy; extra == "docs"
|
|
50
|
+
Requires-Dist: types-requests; extra == "docs"
|
|
51
|
+
Requires-Dist: types-Pillow; extra == "docs"
|
|
52
|
+
Requires-Dist: types-PyYAML; extra == "docs"
|
|
53
|
+
Requires-Dist: sphinx-sitemap; extra == "docs"
|
|
54
|
+
Requires-Dist: sphinxext-opengraph; extra == "docs"
|
|
55
|
+
Requires-Dist: furo; extra == "docs"
|
|
56
|
+
Provides-Extra: dev
|
|
57
|
+
Requires-Dist: pytest; extra == "dev"
|
|
58
|
+
Requires-Dist: coverage[toml]; extra == "dev"
|
|
59
|
+
Requires-Dist: flake8; extra == "dev"
|
|
60
|
+
Requires-Dist: flake8-pyproject; extra == "dev"
|
|
61
|
+
Requires-Dist: pep8-naming; extra == "dev"
|
|
62
|
+
Requires-Dist: mypy; extra == "dev"
|
|
63
|
+
Requires-Dist: types-requests; extra == "dev"
|
|
64
|
+
Requires-Dist: types-PyYAML; extra == "dev"
|
|
65
|
+
Requires-Dist: types-Pillow; extra == "dev"
|
|
66
|
+
Requires-Dist: responses; extra == "dev"
|
|
67
|
+
Dynamic: license-file
|
|
68
|
+
|
|
69
|
+
# amazon-auth
|
|
70
|
+
|
|
71
|
+
[](https://pypi.org/project/amazon-auth)
|
|
72
|
+
[](https://pypi.org/project/amazon-auth)
|
|
73
|
+
[](https://codecov.io/gh/alexdlaird/amazon-auth)
|
|
74
|
+
[](https://github.com/alexdlaird/amazon-auth/actions/workflows/build.yml)
|
|
75
|
+
[](https://amazon-auth.readthedocs.io)
|
|
76
|
+
[](https://github.com/alexdlaird/amazon-auth/blob/main/LICENSE)
|
|
77
|
+
|
|
78
|
+
`amazon-auth` is an unofficial library that signs in to Amazon's consumer website (amazon.com and other Amazon sites)
|
|
79
|
+
and persists the session, so it can be reused from Python or the command line. It handles sign-in, OTP and MFA,
|
|
80
|
+
challenges, and browser sign-in. [`amazon-orders`](https://github.com/alexdlaird/amazon-orders) is built on it.
|
|
81
|
+
|
|
82
|
+
> **Note:** This package works by parsing Amazon's consumer-facing website. As Amazon provides no official API to use,
|
|
83
|
+
> older versions of this package may break at any time, so it's recommended that you use the latest version.
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
`amazon-auth` is available on [PyPI](https://pypi.org/project/amazon-auth/) and can be installed and/or upgraded using `pip`:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
pip install amazon-auth --upgrade
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
That's it! `amazon-auth` is now available as a package to your Python projects and from the command line.
|
|
94
|
+
|
|
95
|
+
If pinning, be sure to use a wildcard for the [minor version](https://semver.org/) (e.g. `==0.1.*`, not `==0.1.0`) to
|
|
96
|
+
ensure you always get the latest stable release.
|
|
97
|
+
|
|
98
|
+
## Basic Usage
|
|
99
|
+
|
|
100
|
+
You'll use [`AmazonSession`](https://amazon-auth.readthedocs.io/api.html#amazonauth.session.AmazonSession) to sign in
|
|
101
|
+
to your Amazon account, then make requests with the signed-in session:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from amazonauth.session import AmazonSession
|
|
105
|
+
|
|
106
|
+
amazon_session = AmazonSession("<AMAZON_EMAIL>",
|
|
107
|
+
"<AMAZON_PASSWORD>")
|
|
108
|
+
amazon_session.login()
|
|
109
|
+
|
|
110
|
+
response = amazon_session.get("https://www.amazon.com/gp/css/homepage.html")
|
|
111
|
+
print(response.parsed.title.text)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The most secure way to sign in is on Amazon's own page, in a browser window, so your credentials never need to be
|
|
115
|
+
stored (this requires the `browser` extra, `pip install amazon-auth[browser]`):
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
amazon-auth login --browser
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The session is persisted, so `AmazonSession().login()` reuses it without credentials.
|
|
122
|
+
|
|
123
|
+
## Documentation
|
|
124
|
+
|
|
125
|
+
For more advanced usage, `amazon-auth`'s official documentation is available
|
|
126
|
+
at [Read the Docs](https://amazon-auth.readthedocs.io).
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
amazon_auth.egg-info/PKG-INFO
|
|
5
|
+
amazon_auth.egg-info/SOURCES.txt
|
|
6
|
+
amazon_auth.egg-info/dependency_links.txt
|
|
7
|
+
amazon_auth.egg-info/entry_points.txt
|
|
8
|
+
amazon_auth.egg-info/requires.txt
|
|
9
|
+
amazon_auth.egg-info/top_level.txt
|
|
10
|
+
amazonauth/__init__.py
|
|
11
|
+
amazonauth/cli.py
|
|
12
|
+
amazonauth/conf.py
|
|
13
|
+
amazonauth/constants.py
|
|
14
|
+
amazonauth/exception.py
|
|
15
|
+
amazonauth/forms.py
|
|
16
|
+
amazonauth/py.typed
|
|
17
|
+
amazonauth/region_data.py
|
|
18
|
+
amazonauth/selectors.py
|
|
19
|
+
amazonauth/session.py
|
|
20
|
+
amazonauth/util.py
|
|
21
|
+
amazonauth/contrib/__init__.py
|
|
22
|
+
amazonauth/contrib/browser/__init__.py
|
|
23
|
+
amazonauth/contrib/browser/playwright.py
|
|
24
|
+
amazonauth/contrib/waf/__init__.py
|
|
25
|
+
amazonauth/contrib/waf/anticaptcha.py
|
|
26
|
+
amazonauth/contrib/waf/base.py
|
|
27
|
+
amazonauth/contrib/waf/capsolver.py
|
|
28
|
+
amazonauth/contrib/waf/twocaptcha.py
|
|
29
|
+
tests/test_cli.py
|
|
30
|
+
tests/test_conf.py
|
|
31
|
+
tests/test_constants.py
|
|
32
|
+
tests/test_package.py
|
|
33
|
+
tests/test_session.py
|
|
34
|
+
tests/test_util.py
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
click>=7.1
|
|
2
|
+
requests>=2.23
|
|
3
|
+
beautifulsoup4>=4.14
|
|
4
|
+
PyYAML>=6.0.3
|
|
5
|
+
Pillow>=9.0.1
|
|
6
|
+
pyotp>=2.9
|
|
7
|
+
|
|
8
|
+
[2captcha]
|
|
9
|
+
2captcha-python
|
|
10
|
+
|
|
11
|
+
[anticaptcha]
|
|
12
|
+
anticaptchaofficial
|
|
13
|
+
|
|
14
|
+
[browser]
|
|
15
|
+
playwright>=1.47.0
|
|
16
|
+
|
|
17
|
+
[capsolver]
|
|
18
|
+
capsolver
|
|
19
|
+
|
|
20
|
+
[captcha]
|
|
21
|
+
amazoncaptcha>=0.4
|
|
22
|
+
|
|
23
|
+
[dev]
|
|
24
|
+
pytest
|
|
25
|
+
coverage[toml]
|
|
26
|
+
flake8
|
|
27
|
+
flake8-pyproject
|
|
28
|
+
pep8-naming
|
|
29
|
+
mypy
|
|
30
|
+
types-requests
|
|
31
|
+
types-PyYAML
|
|
32
|
+
types-Pillow
|
|
33
|
+
responses
|
|
34
|
+
|
|
35
|
+
[docs]
|
|
36
|
+
Sphinx
|
|
37
|
+
sphinx-notfound-page
|
|
38
|
+
sphinx_autodoc_typehints
|
|
39
|
+
mypy
|
|
40
|
+
types-requests
|
|
41
|
+
types-Pillow
|
|
42
|
+
types-PyYAML
|
|
43
|
+
sphinx-sitemap
|
|
44
|
+
sphinxext-opengraph
|
|
45
|
+
furo
|
|
46
|
+
|
|
47
|
+
[lxml]
|
|
48
|
+
lxml
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
__copyright__ = "Copyright (c) 2024-2025 Alex Laird"
|
|
2
|
+
__license__ = "MIT"
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
import platform
|
|
6
|
+
import sys
|
|
7
|
+
from typing import Any, List, Optional
|
|
8
|
+
|
|
9
|
+
import click
|
|
10
|
+
from click.core import Context
|
|
11
|
+
|
|
12
|
+
from amazonauth import __version__
|
|
13
|
+
from amazonauth.conf import AmazonAuthConfig
|
|
14
|
+
from amazonauth.contrib.browser.playwright import PlaywrightBrowserLauncher, PlaywrightBrowserLogin
|
|
15
|
+
from amazonauth.exception import AmazonAuthBrowserNotInstalledError, AmazonAuthError, AmazonAuthSignInError
|
|
16
|
+
from amazonauth.session import AmazonSession, IODefault
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger("amazonauth")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class IOClick(IODefault):
|
|
22
|
+
def echo(self,
|
|
23
|
+
msg: str,
|
|
24
|
+
fg: Optional[str] = None,
|
|
25
|
+
**kwargs: Any) -> None:
|
|
26
|
+
click.secho(msg, fg=fg)
|
|
27
|
+
|
|
28
|
+
def prompt(self,
|
|
29
|
+
msg: str,
|
|
30
|
+
type: Optional[Any] = None,
|
|
31
|
+
**kwargs: Any) -> Any:
|
|
32
|
+
for choice in kwargs.get("choices", []):
|
|
33
|
+
self.echo(choice, **kwargs)
|
|
34
|
+
|
|
35
|
+
return click.prompt(f"--> {msg}", type=type)
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def prompt_for_choice(msg: str,
|
|
39
|
+
choices: List[str]) -> str:
|
|
40
|
+
for number, choice in enumerate(choices, start=1):
|
|
41
|
+
click.echo(f"{number}: {choice}")
|
|
42
|
+
click.echo(f"--> {msg} [1]: ", nl=False)
|
|
43
|
+
|
|
44
|
+
while True:
|
|
45
|
+
key = click.getchar()
|
|
46
|
+
if key in ("\r", "\n"):
|
|
47
|
+
number = 1
|
|
48
|
+
elif key.isdigit() and 1 <= int(key) <= len(choices):
|
|
49
|
+
number = int(key)
|
|
50
|
+
else:
|
|
51
|
+
continue
|
|
52
|
+
|
|
53
|
+
click.echo(number)
|
|
54
|
+
return choices[number - 1]
|
|
55
|
+
|
|
56
|
+
@staticmethod
|
|
57
|
+
def echo_session_expired() -> None:
|
|
58
|
+
click.echo("... Amazon redirected to login, so it wants the persisted session's sign-in confirmed. Call the "
|
|
59
|
+
"`login` command to sign in again, or `login --browser` to log in on Amazon's own page.\n")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class CliAuth:
|
|
63
|
+
def __init__(self,
|
|
64
|
+
amazon_session: AmazonSession) -> None:
|
|
65
|
+
self.amazon_session: AmazonSession = amazon_session
|
|
66
|
+
|
|
67
|
+
def authenticate(self,
|
|
68
|
+
retries: int = 0) -> None:
|
|
69
|
+
amazon_session = self.amazon_session
|
|
70
|
+
try:
|
|
71
|
+
if amazon_session.auth_cookies_stored():
|
|
72
|
+
if amazon_session.username or amazon_session.password:
|
|
73
|
+
click.echo(
|
|
74
|
+
"Info: The given username and password are being ignored because a previous session still "
|
|
75
|
+
"exists. To reauthenticate, call the `login` command.\n")
|
|
76
|
+
else:
|
|
77
|
+
if not amazon_session.username:
|
|
78
|
+
amazon_session.username = click.prompt("Username")
|
|
79
|
+
if not amazon_session.password:
|
|
80
|
+
amazon_session.password = click.prompt("Password", hide_input=True)
|
|
81
|
+
click.echo("")
|
|
82
|
+
|
|
83
|
+
amazon_session.login()
|
|
84
|
+
except AmazonAuthSignInError as e:
|
|
85
|
+
if retries < amazon_session.config.max_auth_retries:
|
|
86
|
+
if amazon_session.username:
|
|
87
|
+
click.secho(str(f"{e}\n"), fg="red")
|
|
88
|
+
click.echo(
|
|
89
|
+
f"Info: Authenticating '{amazon_session.username}' failed. If using 2FA, wait a minute "
|
|
90
|
+
"before retrying with a new OTP.\n")
|
|
91
|
+
|
|
92
|
+
amazon_session.password = None
|
|
93
|
+
|
|
94
|
+
self.authenticate(retries=retries + 1)
|
|
95
|
+
else:
|
|
96
|
+
raise e
|
|
97
|
+
|
|
98
|
+
def authenticate_with_browser(self) -> None:
|
|
99
|
+
browser_login = PlaywrightBrowserLogin(self.amazon_session)
|
|
100
|
+
try:
|
|
101
|
+
browser_login.login()
|
|
102
|
+
except AmazonAuthBrowserNotInstalledError as e:
|
|
103
|
+
if not sys.stdin.isatty():
|
|
104
|
+
raise
|
|
105
|
+
|
|
106
|
+
browser_types = (e.meta or {})["browser_types"]
|
|
107
|
+
if len(browser_types) == 1:
|
|
108
|
+
click.echo(f"Info: {browser_types[0]} isn't installed.\n")
|
|
109
|
+
if not click.confirm(f"--> Download {browser_types[0]} now?", default=True):
|
|
110
|
+
raise
|
|
111
|
+
browser_type = browser_types[0]
|
|
112
|
+
else:
|
|
113
|
+
click.echo("Info: No default browser was found, so one to sign in with needs to be downloaded.\n")
|
|
114
|
+
browser_type = IOClick.prompt_for_choice("Choose a browser to download", browser_types)
|
|
115
|
+
|
|
116
|
+
browser_selected = PlaywrightBrowserLauncher(self.amazon_session.config).install(browser_type)
|
|
117
|
+
click.echo("")
|
|
118
|
+
if browser_selected:
|
|
119
|
+
click.echo(f"Info: Config \"browser\" updated to \"{browser_type}\".\n")
|
|
120
|
+
browser_login.login()
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@click.group()
|
|
124
|
+
@click.option("--username", help="An Amazon username.")
|
|
125
|
+
@click.option("--password", help="An Amazon password.")
|
|
126
|
+
@click.option("--debug", is_flag=True, default=False,
|
|
127
|
+
help="Enable debugging and send output to "
|
|
128
|
+
"command line.")
|
|
129
|
+
@click.option("--config-path",
|
|
130
|
+
help="The config path.")
|
|
131
|
+
@click.option("--max-auth-attempts",
|
|
132
|
+
help="The max auth loop attempts to make (successes and failures), passing this overrides config value.")
|
|
133
|
+
@click.option("--output-dir",
|
|
134
|
+
help="The directory where any output files should be produced, passing this overrides config value.")
|
|
135
|
+
@click.option("--domain",
|
|
136
|
+
help="The Amazon domain to target (e.g. amazon.com, amazon.co.uk, amazon.com.au). "
|
|
137
|
+
"Defaults to amazon.com.")
|
|
138
|
+
@click.pass_context
|
|
139
|
+
def amazon_auth_cli(ctx: Context,
|
|
140
|
+
**kwargs: Any) -> None:
|
|
141
|
+
"""
|
|
142
|
+
amazon-auth signs in to Amazon's consumer website and persists the session, so it can be reused from the
|
|
143
|
+
CLI or Python.
|
|
144
|
+
|
|
145
|
+
Documentation can be found at https://amazon-auth.readthedocs.io.
|
|
146
|
+
"""
|
|
147
|
+
ctx.ensure_object(dict)
|
|
148
|
+
for key, value in kwargs.items():
|
|
149
|
+
if value:
|
|
150
|
+
ctx.obj[key] = value
|
|
151
|
+
|
|
152
|
+
if kwargs["debug"]:
|
|
153
|
+
logger.setLevel(logging.DEBUG)
|
|
154
|
+
logger.addHandler(logging.StreamHandler())
|
|
155
|
+
|
|
156
|
+
data = {}
|
|
157
|
+
if kwargs.get("output_dir"):
|
|
158
|
+
data["output_dir"] = kwargs["output_dir"]
|
|
159
|
+
if kwargs.get("max_auth_attempts"):
|
|
160
|
+
data["max_auth_attempts"] = kwargs["max_auth_attempts"]
|
|
161
|
+
if kwargs.get("domain"):
|
|
162
|
+
data["domain"] = kwargs["domain"]
|
|
163
|
+
ctx.obj["conf_data"] = data
|
|
164
|
+
|
|
165
|
+
if ctx.invoked_subcommand == "version":
|
|
166
|
+
return
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
ctx.obj["conf"] = AmazonAuthConfig(config_path=kwargs.get("config_path"),
|
|
170
|
+
data=data)
|
|
171
|
+
except AmazonAuthError as e:
|
|
172
|
+
ctx.fail(str(e))
|
|
173
|
+
|
|
174
|
+
username = kwargs.get("username")
|
|
175
|
+
password = kwargs.get("password")
|
|
176
|
+
|
|
177
|
+
amazon_session = AmazonSession(username,
|
|
178
|
+
password,
|
|
179
|
+
debug=kwargs["debug"],
|
|
180
|
+
io=IOClick(),
|
|
181
|
+
config=ctx.obj["conf"])
|
|
182
|
+
|
|
183
|
+
ctx.obj["amazon_session"] = amazon_session
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
@amazon_auth_cli.command(short_help="Check if a persisted session exists.")
|
|
187
|
+
@click.pass_context
|
|
188
|
+
@click.option("--verify", is_flag=True, default=False,
|
|
189
|
+
help="Also ask Amazon whether it still accepts the persisted session.")
|
|
190
|
+
def check_session(ctx: Context, **kwargs: Any) -> None:
|
|
191
|
+
"""
|
|
192
|
+
Check if a persisted session exists, meaning commands can be called without needing to provide credentials.
|
|
193
|
+
"""
|
|
194
|
+
amazon_session = ctx.obj["amazon_session"]
|
|
195
|
+
|
|
196
|
+
try:
|
|
197
|
+
if amazon_session.check_session(verify=kwargs["verify"]):
|
|
198
|
+
if kwargs["verify"]:
|
|
199
|
+
click.echo("Info: A persisted session exists, and Amazon accepts it.\n")
|
|
200
|
+
else:
|
|
201
|
+
click.echo("Info: A persisted session exists.\n")
|
|
202
|
+
elif amazon_session.auth_cookies_stored():
|
|
203
|
+
click.echo("Info: A persisted session exists, but Amazon no longer accepts it.\n")
|
|
204
|
+
IOClick.echo_session_expired()
|
|
205
|
+
else:
|
|
206
|
+
click.echo("Info: No persisted session exists.\n")
|
|
207
|
+
except AmazonAuthError as e:
|
|
208
|
+
logger.debug("An error occurred.", exc_info=True)
|
|
209
|
+
ctx.fail(str(e))
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@amazon_auth_cli.command()
|
|
213
|
+
@click.pass_context
|
|
214
|
+
@click.option("--browser", is_flag=True, default=False,
|
|
215
|
+
help="Sign in with a browser window, so your credentials never need to be stored. "
|
|
216
|
+
"Requires the browser extra.")
|
|
217
|
+
def login(ctx: Context, **kwargs: Any) -> None:
|
|
218
|
+
"""
|
|
219
|
+
Log in to establish an Amazon session and cookies.
|
|
220
|
+
"""
|
|
221
|
+
amazon_session = ctx.obj["amazon_session"]
|
|
222
|
+
|
|
223
|
+
try:
|
|
224
|
+
if amazon_session.auth_cookies_stored():
|
|
225
|
+
click.echo("Info: Logging out of the persisted session first, so this login starts fresh.\n")
|
|
226
|
+
amazon_session.logout()
|
|
227
|
+
|
|
228
|
+
if kwargs["browser"]:
|
|
229
|
+
CliAuth(amazon_session).authenticate_with_browser()
|
|
230
|
+
else:
|
|
231
|
+
CliAuth(amazon_session).authenticate()
|
|
232
|
+
except AmazonAuthError as e:
|
|
233
|
+
logger.debug("An error occurred.", exc_info=True)
|
|
234
|
+
ctx.fail(str(e))
|
|
235
|
+
|
|
236
|
+
click.echo("Info: Successfully logged in to Amazon, session persisted.\n")
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@amazon_auth_cli.command()
|
|
240
|
+
@click.pass_context
|
|
241
|
+
def logout(ctx: Context) -> None:
|
|
242
|
+
"""
|
|
243
|
+
Log out of existing Amazon sessions and clear cookies.
|
|
244
|
+
"""
|
|
245
|
+
amazon_session = ctx.obj["amazon_session"]
|
|
246
|
+
amazon_session.logout()
|
|
247
|
+
|
|
248
|
+
click.echo("Info: Successfully logged out of Amazon.\n")
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
@amazon_auth_cli.command()
|
|
252
|
+
@click.pass_context
|
|
253
|
+
def version(ctx: Context) -> None:
|
|
254
|
+
"""
|
|
255
|
+
Show the banner and package version.
|
|
256
|
+
"""
|
|
257
|
+
click.echo(f"amazon-auth/{__version__} Python/{platform.python_version()}")
|
|
258
|
+
ctx.exit(0)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
if __name__ == "__main__":
|
|
262
|
+
amazon_auth_cli(obj={})
|