tokentoss 0.1.0__py3-none-any.whl

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,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: tokentoss
3
+ Version: 0.1.0
4
+ Summary: OAuth authentication from Jupyter notebooks for IAP-protected GCP services
5
+ Project-URL: Homepage, https://github.com/NicholasGrundl/tokentoss
6
+ Project-URL: Repository, https://github.com/NicholasGrundl/tokentoss
7
+ Project-URL: Issues, https://github.com/NicholasGrundl/tokentoss/issues
8
+ Project-URL: Changelog, https://github.com/NicholasGrundl/tokentoss/releases
9
+ Author: Nicholas Grundl
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: authentication,gcp,iap,jupyter,oauth
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: Jupyter
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: anywidget>=0.9.0
23
+ Requires-Dist: google-auth-oauthlib>=1.2.0
24
+ Requires-Dist: google-auth>=2.23.0
25
+ Requires-Dist: platformdirs>=4.0.0
26
+ Requires-Dist: requests>=2.31.0
27
+ Description-Content-Type: text/markdown
28
+
29
+ # tokentoss
30
+
31
+ [![PyPI version](https://img.shields.io/pypi/v/tokentoss)](https://pypi.org/project/tokentoss/)
32
+ [![CI](https://github.com/NicholasGrundl/tokentoss/actions/workflows/ci.yml/badge.svg)](https://github.com/NicholasGrundl/tokentoss/actions/workflows/ci.yml)
33
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
34
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
35
+
36
+ OAuth authentication from Jupyter notebooks for IAP-protected GCP services.
37
+
38
+ ## Features
39
+
40
+ - **anywidget** with "Sign in with Google" button
41
+ - **Authorization Code flow with PKCE** for security and refresh tokens
42
+ - **Token persistence** across sessions
43
+ - **IAPClient** for authenticated HTTP requests with auto-refresh
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install tokentoss
49
+ ```
50
+
51
+ Or with uv:
52
+
53
+ ```bash
54
+ uv add tokentoss
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ ### 1. One-Time GCP Setup
60
+
61
+ 1. Create a Desktop OAuth client in [GCP Console](https://console.cloud.google.com/apis/credentials)
62
+ 2. Download `client_secrets.json`
63
+ 3. Add the Desktop client ID to your IAP's programmatic access allowlist
64
+ 4. Grant yourself the "IAP-secured Web App User" role
65
+
66
+ ### 2. Configure Credentials
67
+
68
+ Use the `ConfigureWidget` for a password-safe setup (credentials never appear in notebook source):
69
+
70
+ ```python
71
+ from tokentoss import ConfigureWidget
72
+
73
+ display(ConfigureWidget())
74
+ # Enter Client ID and Client Secret, click "Configure"
75
+ ```
76
+
77
+ Or configure programmatically:
78
+
79
+ ```python
80
+ import tokentoss
81
+
82
+ tokentoss.configure(client_id="YOUR_CLIENT_ID", client_secret="YOUR_SECRET")
83
+ ```
84
+
85
+ Credentials are stored to `~/.config/tokentoss/client_secrets.json` so they stay out of version control.
86
+
87
+ ### 3. Authenticate in Jupyter
88
+
89
+ ```python
90
+ from tokentoss import GoogleAuthWidget
91
+
92
+ # Widget auto-discovers credentials from the standard config location
93
+ widget = GoogleAuthWidget()
94
+ display(widget)
95
+
96
+ # Click "Sign in with Google" and complete the flow
97
+ # Widget shows "Signed in as user@example.com"
98
+ ```
99
+
100
+ ### 4. Make Authenticated Requests
101
+
102
+ ```python
103
+ from tokentoss import IAPClient
104
+
105
+ # Create client (auto-discovers credentials)
106
+ client = IAPClient(base_url="https://my-iap-service.run.app")
107
+
108
+ # Make requests - ID token added automatically
109
+ data = client.get_json("/api/data")
110
+ response = client.post("/api/items", json={"name": "test"})
111
+ ```
112
+
113
+ ## How It Works
114
+
115
+ 1. **`configure()`** stores OAuth client credentials to a standard platform location
116
+ 2. **Widget** opens a popup for Google OAuth
117
+ 3. User authenticates and grants consent
118
+ 4. **AuthManager** exchanges auth code for tokens (with PKCE)
119
+ 5. Tokens are stored securely (file permissions 0600)
120
+ 6. **IAPClient** uses ID token for IAP authentication
121
+ 7. Tokens refresh automatically when expired
122
+
123
+ ## Development
124
+
125
+ ```bash
126
+ # Clone and install
127
+ git clone https://github.com/NicholasGrundl/tokentoss.git
128
+ cd tokentoss
129
+ uv sync --group dev
130
+
131
+ # Run tests
132
+ uv run pytest
133
+
134
+ # Lint and format
135
+ uv run ruff format src/ tests/
136
+ uv run ruff check src/ tests/
137
+
138
+ # Type check (advisory)
139
+ uv run ty check src/
140
+
141
+ # Start Jupyter for testing
142
+ uv run jupyter lab
143
+ ```
144
+
145
+ ## License
146
+
147
+ MIT
@@ -0,0 +1,14 @@
1
+ tokentoss/__init__.py,sha256=vj0RbOdn1IZfN7_j_VAc01je2oQNytii8MAIv0HSZVQ,2234
2
+ tokentoss/_logging.py,sha256=qal8EL6V9VZMCKpjcC1irH4PwSlJBFzz_vKIJ7VZcB0,1279
3
+ tokentoss/_telemetry.py,sha256=jQCeoebY_wXxpGFs2jibiP-cHP7Nss94vr_K8ojxOv8,392
4
+ tokentoss/auth_manager.py,sha256=rpzlPwWhsbBsto737sfkJMv8WNcHavHVmxWPuwpT0ic,17214
5
+ tokentoss/client.py,sha256=8hCBvK7h_sx941k5bdYPbGag939NBD0lgsewmbZV2lo,8289
6
+ tokentoss/configure_widget.py,sha256=upvFSpED4ZktZaoY9KnKUazJTt-DlxAmnfurUNh35wA,7363
7
+ tokentoss/exceptions.py,sha256=j5uPbWFImoCXpfdmI1_GEzojDVwUTQsjrgRoxzmj2So,1472
8
+ tokentoss/setup.py,sha256=JhGvQOn8_q3d5mdSAvDv_dC3ApBjmOmlWXQ6AH2Tg8o,6384
9
+ tokentoss/storage.py,sha256=jplp52LmbLKsZJmqX8KtEGf2BpjuDqnxnoiBVaf_EOE,6064
10
+ tokentoss/widget.py,sha256=ChTHGr4Wjap4gD0khYc9YcMmaKcCfxSZfDgKcfc-b1s,25021
11
+ tokentoss-0.1.0.dist-info/METADATA,sha256=ssK2q8HBWp5dk_plMC8f1x9yJSOrbvF4S73166VljBs,4266
12
+ tokentoss-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
+ tokentoss-0.1.0.dist-info/licenses/LICENSE,sha256=7qMxL-61vLTFKNUYv9VVDM5Aeussm_j0RyuPLxaS8c8,1072
14
+ tokentoss-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Nicholas Grundl
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.