pfmsoft-eve-auth-manager 0.4.2__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.
- pfmsoft_eve_auth_manager-0.4.2/LICENSE +21 -0
- pfmsoft_eve_auth_manager-0.4.2/PKG-INFO +456 -0
- pfmsoft_eve_auth_manager-0.4.2/README.md +433 -0
- pfmsoft_eve_auth_manager-0.4.2/pyproject.toml +81 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/__init__.py +13 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/auth/__init__.py +0 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/auth/code_challenge.py +53 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/auth/oauth_tokens.py +401 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/auth/request_authentication_code.py +352 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/auth/secure_random_string.py +31 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/auth/token_tools.py +232 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/__init__.py +18 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/authorize.py +217 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/characters/__init__.py +19 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/characters/add.py +167 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/characters/display.py +165 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/characters/refresh.py +104 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/characters/revoke.py +122 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/characters/search_id.py +114 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/credentials/__init__.py +15 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/credentials/add.py +86 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/credentials/display.py +212 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/credentials/remove.py +49 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/helpers.py +44 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/main_typer.py +58 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/util/__init__.py +10 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/util/reset.py +83 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/cli/version.py +20 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/helpers/__init__.py +0 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/helpers/http_session_factory.py +80 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/helpers/json_io.py +256 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/helpers/markdown_table.py +247 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/helpers/package_resource.py +16 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/helpers/save_text_file.py +43 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/helpers/whenever/__init__.py +4 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/helpers/whenever/instant_helpers.py +41 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/logging_config.py +118 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/models.py +232 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/protocols.py +312 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/py.typed +0 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/settings.py +87 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/sqlite/__init__.py +0 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/sqlite/connection_helpers.py +121 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/sqlite/manager.py +633 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/sqlite/query_helpers.py +255 -0
- pfmsoft_eve_auth_manager-0.4.2/src/pfmsoft/eve_auth_manager/sqlite/table_definitions.sql +39 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chad Lowe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pfmsoft-eve-auth-manager
|
|
3
|
+
Version: 0.4.2
|
|
4
|
+
Summary: CLI and API helpers for acquiring, storing, and refreshing EVE Online ESI OAuth tokens
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Dist: httpx2>=2.5.0
|
|
8
|
+
Requires-Dist: mdformat>=1.0.0
|
|
9
|
+
Requires-Dist: mdformat-gfm>=1.0.0
|
|
10
|
+
Requires-Dist: pfmsoft-eve-snippets>=0.1.4
|
|
11
|
+
Requires-Dist: pydantic>=2.13.4
|
|
12
|
+
Requires-Dist: pydantic-settings>=2.14.2
|
|
13
|
+
Requires-Dist: pyjwt>=2.13.0
|
|
14
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
15
|
+
Requires-Dist: rich>=15.0.0
|
|
16
|
+
Requires-Dist: typer>=0.26.8
|
|
17
|
+
Requires-Dist: whenever>=0.10.2
|
|
18
|
+
Requires-Python: >=3.14
|
|
19
|
+
Project-URL: Documentation, https://github.com/DonalChilde/pfmsoft-eve-auth-manager#readme
|
|
20
|
+
Project-URL: Issues, https://github.com/DonalChilde/pfmsoft-eve-auth-manager/issues
|
|
21
|
+
Project-URL: Source, https://github.com/DonalChilde/pfmsoft-eve-auth-manager
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
## Eve Auth Manager
|
|
25
|
+
|
|
26
|
+
Eve Auth Manager is a CLI-first tool for acquiring, storing, retrieving,
|
|
27
|
+
refreshing, and revoking EVE Online ESI OAuth tokens.
|
|
28
|
+
|
|
29
|
+
It stores ESI application credentials and authorized character state in a local
|
|
30
|
+
SQLite database, and can emit fresh authorization payloads for use by other
|
|
31
|
+
tools and scripts.
|
|
32
|
+
|
|
33
|
+
The current command set is feature-stable for this version. Documentation and
|
|
34
|
+
usability improvements are still ongoing.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- Store ESI application credentials in a local SQLite auth database.
|
|
39
|
+
- Add and manage authorized EVE characters.
|
|
40
|
+
- Refresh or revoke one character or all characters for a credential.
|
|
41
|
+
- Search character IDs from names using the ESI universe IDs endpoint.
|
|
42
|
+
- Emit authorization JSON for other scripts and applications.
|
|
43
|
+
- Reset and recreate the auth database for clean development or test state.
|
|
44
|
+
- Use the SQLite-backed auth manager API for programmatic operations after
|
|
45
|
+
initial CLI authorization.
|
|
46
|
+
|
|
47
|
+
## Requirements
|
|
48
|
+
|
|
49
|
+
- Python 3.14 or newer
|
|
50
|
+
- uv
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
### Option 1: uv-managed project environment
|
|
55
|
+
|
|
56
|
+
Clone the repository and install the project plus development dependencies:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
git clone https://github.com/DonalChilde/Eve-Auth-Manager.git
|
|
60
|
+
cd Eve-Auth-Manager
|
|
61
|
+
uv sync
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Run the CLI with:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
uv run eve-auth --help
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Option 2: Install from source
|
|
71
|
+
|
|
72
|
+
Install the project into your current Python environment:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/DonalChilde/Eve-Auth-Manager.git
|
|
76
|
+
cd Eve-Auth-Manager
|
|
77
|
+
python -m pip install .
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For local development, editable install is also supported:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
python -m pip install -e .
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Then run:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
eve-auth --help
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
Settings are loaded from environment variables prefixed with
|
|
95
|
+
`ESI_AUTH_MANAGER_`.
|
|
96
|
+
|
|
97
|
+
Supported settings:
|
|
98
|
+
|
|
99
|
+
- `ESI_AUTH_MANAGER_AUTH_DB_PATH`: Path to the SQLite auth database file.
|
|
100
|
+
|
|
101
|
+
By default, the auth database is created in the platform-specific application
|
|
102
|
+
data directory as `auth_manager.db`. Log files are written in a sibling
|
|
103
|
+
`logs` directory.
|
|
104
|
+
|
|
105
|
+
## CLI Overview
|
|
106
|
+
|
|
107
|
+
Top-level commands:
|
|
108
|
+
|
|
109
|
+
- `authorize`: Refresh a selected character if needed and emit an
|
|
110
|
+
`AuthorizedDict` JSON payload.
|
|
111
|
+
- `credentials`: Add, display, and remove stored ESI application credentials.
|
|
112
|
+
- `characters`: Add, display, refresh, revoke, and search character
|
|
113
|
+
authorizations.
|
|
114
|
+
- `util`: Maintenance commands such as database reset.
|
|
115
|
+
- `version`: Show the installed CLI version and project URL.
|
|
116
|
+
|
|
117
|
+
## Quick Start
|
|
118
|
+
|
|
119
|
+
### 1. Create `credentials.json` from EVE Developers
|
|
120
|
+
|
|
121
|
+
1. Go to https://developers.eveonline.com/applications and sign in.
|
|
122
|
+
2. Create a new ESI application, or open an existing one.
|
|
123
|
+
3. Copy the application JSON payload from the portal.
|
|
124
|
+
4. Save it locally as `credentials.json`.
|
|
125
|
+
|
|
126
|
+
Expected JSON shape:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"name": "My ESI App",
|
|
131
|
+
"description": "Optional human-readable description",
|
|
132
|
+
"clientId": "your_client_id",
|
|
133
|
+
"clientSecret": "your_client_secret",
|
|
134
|
+
"callbackUrl": "http://localhost:8080/callback",
|
|
135
|
+
"scopes": ["scope1", "scope2"]
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 2. Inspect top-level help
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
uv run eve-auth --help
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 3. Check installed version
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
uv run eve-auth version
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Example output:
|
|
152
|
+
|
|
153
|
+
```text
|
|
154
|
+
esi-auth-manager version 0.4.0
|
|
155
|
+
Project URL: https://github.com/DonalChilde/Eve-Auth-Manager
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 4. Add ESI app credentials
|
|
159
|
+
|
|
160
|
+
From a JSON file:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
uv run eve-auth credentials add --from ./credentials.json
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
From stdin:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
cat ./credentials.json | uv run eve-auth credentials add --from -
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 5. Display credentials
|
|
173
|
+
|
|
174
|
+
Summary:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
uv run eve-auth credentials display
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Detailed by credential ID:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
uv run eve-auth credentials display --cred-id <credential-uuid>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 6. Authorize and add a character
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
uv run eve-auth characters add <character-id> --cred-id <credential-uuid>
|
|
190
|
+
# or
|
|
191
|
+
uv run eve-auth characters add <character-id> --cred-name <credential-name>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 7. Get an authorization payload
|
|
195
|
+
|
|
196
|
+
Use `authorize` to refresh a character if needed and emit an `AuthorizedDict`
|
|
197
|
+
JSON payload.
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
uv run eve-auth authorize --cred-name <credential-name> --character-id <character-id> --indent 2 --min-seconds 1200
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
`--min-seconds 1200` requests refresh behavior for the maximum supported token
|
|
204
|
+
lifetime window before a refresh is skipped.
|
|
205
|
+
|
|
206
|
+
Example output:
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"cred_id": "credential UUID as a string",
|
|
211
|
+
"character_id": 123456789,
|
|
212
|
+
"character_name": "Character Name",
|
|
213
|
+
"access_token": "ESI bearer token",
|
|
214
|
+
"expires_at": 1735689600
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Field meanings:
|
|
219
|
+
|
|
220
|
+
- `cred_id`: Credential UUID used for the authorization.
|
|
221
|
+
- `character_id`: EVE character ID associated with the token.
|
|
222
|
+
- `character_name`: EVE character name from the validated token.
|
|
223
|
+
- `access_token`: Bearer token to send in the `Authorization` header.
|
|
224
|
+
- `expires_at`: Unix timestamp, in seconds, when the access token expires.
|
|
225
|
+
|
|
226
|
+
You can paste the access token into the
|
|
227
|
+
[ESI API Explorer](https://developers.eveonline.com/api-explorer) to explore
|
|
228
|
+
authenticated endpoints.
|
|
229
|
+
|
|
230
|
+
Specific endpoints require scopes that were granted when the application
|
|
231
|
+
credentials were created.
|
|
232
|
+
|
|
233
|
+
### 8. Use the authorization payload in shell scripts
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Extract fields with Python.
|
|
237
|
+
AUTH_JSON="$(uv run eve-auth authorize --cred-id <credential-uuid> --character-id <character-id>)"
|
|
238
|
+
ACCESS_TOKEN="$(printf '%s' "$AUTH_JSON" | python -c "import sys, json; print(json.load(sys.stdin)['access_token'])")"
|
|
239
|
+
CHARACTER_ID="$(printf '%s' "$AUTH_JSON" | python -c "import sys, json; print(json.load(sys.stdin)['character_id'])")"
|
|
240
|
+
USER_AGENT="eve-auth-manager-readme-example/0.1"
|
|
241
|
+
|
|
242
|
+
curl -H "Authorization: Bearer $ACCESS_TOKEN" \
|
|
243
|
+
-H "User-Agent: $USER_AGENT" \
|
|
244
|
+
"https://esi.evetech.net/characters/$CHARACTER_ID/attributes/?datasource=tranquility"
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# Extract fields with jq.
|
|
249
|
+
uv run eve-auth authorize --cred-id <credential-uuid> --character-id <character-id> \
|
|
250
|
+
| jq -r '"\(.access_token) \(.character_id)"' \
|
|
251
|
+
| {
|
|
252
|
+
read -r ACCESS_TOKEN CHARACTER_ID
|
|
253
|
+
USER_AGENT="eve-auth-manager-readme-example/0.1"
|
|
254
|
+
curl -H "Authorization: Bearer $ACCESS_TOKEN" \
|
|
255
|
+
-H "User-Agent: $USER_AGENT" \
|
|
256
|
+
"https://esi.evetech.net/characters/$CHARACTER_ID/attributes/?datasource=tranquility"
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Save output to a file and read it later.
|
|
262
|
+
uv run eve-auth authorize --cred-id <credential-uuid> --character-id <character-id> \
|
|
263
|
+
> /tmp/eve-auth-authorized.json
|
|
264
|
+
|
|
265
|
+
ACCESS_TOKEN="$(jq -r '.access_token' /tmp/eve-auth-authorized.json)"
|
|
266
|
+
CHARACTER_ID="$(jq -r '.character_id' /tmp/eve-auth-authorized.json)"
|
|
267
|
+
USER_AGENT="eve-auth-manager-readme-example/0.1"
|
|
268
|
+
|
|
269
|
+
curl -H "Authorization: Bearer $ACCESS_TOKEN" \
|
|
270
|
+
-H "User-Agent: $USER_AGENT" \
|
|
271
|
+
"https://esi.evetech.net/characters/$CHARACTER_ID/attributes/?datasource=tranquility"
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### 9. Use the authorization payload in Python
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
# A Python script that accepts piped AuthorizedDict JSON from stdin.
|
|
278
|
+
import json
|
|
279
|
+
import sys
|
|
280
|
+
from urllib.request import Request, urlopen
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
authorized = json.load(sys.stdin)
|
|
284
|
+
access_token = authorized["access_token"]
|
|
285
|
+
character_id = authorized["character_id"]
|
|
286
|
+
user_agent = "eve-auth-manager-readme-example/0.1"
|
|
287
|
+
|
|
288
|
+
request = Request(
|
|
289
|
+
url=(
|
|
290
|
+
f"https://esi.evetech.net/characters/{character_id}/attributes/"
|
|
291
|
+
"?datasource=tranquility"
|
|
292
|
+
),
|
|
293
|
+
headers={"Authorization": f"Bearer {access_token}", "User-Agent": user_agent},
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
with urlopen(request) as response:
|
|
297
|
+
print(response.read().decode("utf-8"))
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Example invocation for the Python script above.
|
|
302
|
+
uv run eve-auth authorize --cred-id <credential-uuid> --character-id <character-id> \
|
|
303
|
+
| python ./esi_attributes_from_authorize.py
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
```python
|
|
307
|
+
# A PEP 723 Python script that accepts piped AuthorizedDict JSON from stdin.
|
|
308
|
+
# /// script
|
|
309
|
+
# requires-python = ">=3.14"
|
|
310
|
+
# dependencies = [
|
|
311
|
+
# "httpx2>=2.5.0",
|
|
312
|
+
# "typer>=0.26.8",
|
|
313
|
+
# ]
|
|
314
|
+
# ///
|
|
315
|
+
|
|
316
|
+
import json
|
|
317
|
+
import sys
|
|
318
|
+
|
|
319
|
+
import typer
|
|
320
|
+
from httpx2 import Client
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def main() -> None:
|
|
324
|
+
authorized = json.load(sys.stdin)
|
|
325
|
+
access_token = authorized["access_token"]
|
|
326
|
+
character_id = authorized["character_id"]
|
|
327
|
+
user_agent = "eve-auth-manager-readme-example/0.1"
|
|
328
|
+
url = (
|
|
329
|
+
f"https://esi.evetech.net/characters/{character_id}/attributes/"
|
|
330
|
+
"?datasource=tranquility"
|
|
331
|
+
)
|
|
332
|
+
headers = {"Authorization": f"Bearer {access_token}", "User-Agent": user_agent}
|
|
333
|
+
with Client(headers=headers) as client:
|
|
334
|
+
response = client.get(url)
|
|
335
|
+
response.raise_for_status()
|
|
336
|
+
|
|
337
|
+
typer.echo(response.text)
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
if __name__ == "__main__":
|
|
341
|
+
typer.run(main)
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# Example invocation for the PEP 723 script above.
|
|
346
|
+
uv run eve-auth authorize --cred-id <credential-uuid> --character-id <character-id> \
|
|
347
|
+
| uv run ./esi_attributes_from_authorize.py
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### 10. Display character authorizations
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
uv run eve-auth characters display --cred-id <credential-uuid>
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### 11. Refresh character tokens
|
|
357
|
+
|
|
358
|
+
Refresh all for a credential:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
uv run eve-auth characters refresh --cred-id <credential-uuid>
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Refresh one character:
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
uv run eve-auth characters refresh --cred-id <credential-uuid> <character-id>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### 12. Revoke character authorizations
|
|
371
|
+
|
|
372
|
+
Revoke all authorized characters for a credential:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
uv run eve-auth characters revoke --cred-id <credential-uuid>
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Revoke specific characters:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
uv run eve-auth characters revoke --cred-id <credential-uuid> --character-id <id1> --character-id <id2>
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### 13. Search character IDs
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
uv run eve-auth characters search --search Tritanium
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### 14. Reset the auth database
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
uv run eve-auth util reset --force
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Using the API
|
|
397
|
+
|
|
398
|
+
Most programmatic operations are available through the SQLite-backed auth
|
|
399
|
+
manager after credentials and characters have been added.
|
|
400
|
+
|
|
401
|
+
```python
|
|
402
|
+
from pathlib import Path
|
|
403
|
+
|
|
404
|
+
from eve_auth_manager.sqlite.manager import SqliteAuthManager
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
db_path = Path("./auth_manager.db")
|
|
408
|
+
|
|
409
|
+
with SqliteAuthManager(db_path) as auth_manager:
|
|
410
|
+
credential = auth_manager.get_credential(cred_name="my-app")
|
|
411
|
+
characters = auth_manager.get_all_characters(credential.cred_id)
|
|
412
|
+
|
|
413
|
+
print([character.character_name for character in characters])
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
## Development
|
|
417
|
+
|
|
418
|
+
Set up the project:
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
uv sync
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Run tests:
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
uv run pytest
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Run coverage for the package:
|
|
431
|
+
|
|
432
|
+
```bash
|
|
433
|
+
uv run pytest tests/eve_auth_manager --cov=src/eve_auth_manager --cov-report=term-missing
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Check formatting and linting:
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
uv run ruff format --check
|
|
440
|
+
uv run ruff check
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Format Python files:
|
|
444
|
+
|
|
445
|
+
```bash
|
|
446
|
+
uv run ruff format
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## Testing
|
|
450
|
+
|
|
451
|
+
The automated test suite currently covers the full `src/eve_auth_manager`
|
|
452
|
+
package with complete statement and branch coverage.
|
|
453
|
+
|
|
454
|
+
## License
|
|
455
|
+
|
|
456
|
+
MIT. See `LICENSE`.
|