Skip to content

Commit 8c0c6a8

Browse files
committed
auth: Update location
1 parent cc9de47 commit 8c0c6a8

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

src/amp/admin/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class AdminClient:
2121
Args:
2222
base_url: Base URL for Admin API (e.g., 'http://localhost:8080')
2323
auth_token: Optional Bearer token for authentication (highest priority)
24-
auth: If True, load auth token from ~/.amp-cli-config (shared with TS CLI)
24+
auth: If True, load auth token from ~/.amp/cache (shared with TS CLI)
2525
2626
Authentication Priority (highest to lowest):
2727
1. Explicit auth_token parameter
2828
2. AMP_AUTH_TOKEN environment variable
29-
3. auth=True - reads from ~/.amp-cli-config/amp_cli_auth
29+
3. auth=True - reads from ~/.amp/cache/amp_cli_auth
3030
3131
Example:
3232
>>> # Use amp auth from file
@@ -46,7 +46,7 @@ def __init__(self, base_url: str, auth_token: Optional[str] = None, auth: bool =
4646
Args:
4747
base_url: Base URL for Admin API (e.g., 'http://localhost:8080')
4848
auth_token: Optional Bearer token for authentication
49-
auth: If True, load auth token from ~/.amp-cli-config
49+
auth: If True, load auth token from ~/.amp/cache
5050
5151
Raises:
5252
ValueError: If both auth=True and auth_token are provided

src/amp/auth/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Authentication module for amp Python client.
22
33
Provides Privy authentication support compatible with the TypeScript CLI.
4-
Reads and manages auth tokens from ~/.amp-cli-config.
4+
Reads and manages auth tokens from ~/.amp/cache.
55
"""
66

77
from .device_flow import interactive_device_login

src/amp/auth/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class AuthStorage(BaseModel):
12-
"""Auth storage schema for ~/.amp-cli-config file.
12+
"""Auth storage schema for ~/.amp/cache/amp_cli_auth file.
1313
1414
Matches the TypeScript AuthStorageSchema so they can share auth.
1515
"""

src/amp/auth/service.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Auth service for managing Privy authentication.
22
3-
Handles loading, refreshing, and persisting auth tokens from ~/.amp-cli-config.
3+
Handles loading, refreshing, and persisting auth tokens from ~/.amp/cache.
44
Compatible with the TypeScript CLI authentication system.
55
"""
66

@@ -17,15 +17,15 @@
1717
AUTH_PLATFORM_URL = 'https://auth.amp.thegraph.com/'
1818

1919
# Storage location (matches TypeScript implementation)
20-
# TypeScript CLI uses: ~/.amp-cli-config/amp_cli_auth (directory with file inside)
21-
AUTH_CONFIG_DIR = Path.home() / '.amp-cli-config'
20+
# TypeScript CLI uses: ~/.amp/cache/amp_cli_auth (directory with file inside)
21+
AUTH_CONFIG_DIR = Path.home() / '.amp' / 'cache'
2222
AUTH_CONFIG_FILE = AUTH_CONFIG_DIR / 'amp_cli_auth'
2323

2424

2525
class AuthService:
2626
"""Service for managing Privy authentication tokens.
2727
28-
Loads tokens from ~/.amp-cli-config (shared with TypeScript CLI),
28+
Loads tokens from ~/.amp/cache (shared with TypeScript CLI),
2929
automatically refreshes expired tokens, and persists updates.
3030
3131
Example:
@@ -38,7 +38,7 @@ def __init__(self, config_path: Optional[Path] = None):
3838
"""Initialize auth service.
3939
4040
Args:
41-
config_path: Optional custom path to config file (defaults to ~/.amp-cli-config/amp_cli_auth)
41+
config_path: Optional custom path to config file (defaults to ~/.amp/cache/amp_cli_auth)
4242
"""
4343
self.config_path = config_path or AUTH_CONFIG_FILE
4444
self._http = httpx.Client(timeout=30.0)
@@ -47,7 +47,7 @@ def is_authenticated(self) -> bool:
4747
"""Check if user is authenticated.
4848
4949
Returns:
50-
True if valid auth exists in ~/.amp-cli-config
50+
True if valid auth exists in ~/.amp/cache
5151
"""
5252
try:
5353
auth = self.load_auth()
@@ -56,7 +56,7 @@ def is_authenticated(self) -> bool:
5656
return False
5757

5858
def load_auth(self) -> Optional[AuthStorage]:
59-
"""Load auth from ~/.amp-cli-config/amp_cli_auth file.
59+
"""Load auth from ~/.amp/cache/amp_cli_auth file.
6060
6161
Returns:
6262
AuthStorage if found, None if not authenticated
@@ -75,7 +75,7 @@ def load_auth(self) -> Optional[AuthStorage]:
7575
return AuthStorage.model_validate(auth_data)
7676

7777
def save_auth(self, auth: AuthStorage) -> None:
78-
"""Save auth to ~/.amp-cli-config/amp_cli_auth file.
78+
"""Save auth to ~/.amp/cache/amp_cli_auth file.
7979
8080
Args:
8181
auth: Auth data to persist
@@ -97,7 +97,7 @@ def get_token(self) -> str:
9797
Valid access token string
9898
9999
Raises:
100-
FileNotFoundError: If not authenticated (no ~/.amp-cli-config)
100+
FileNotFoundError: If not authenticated (no ~/.amp/cache)
101101
ValueError: If auth data is invalid or refresh fails
102102
"""
103103
auth = self.load_auth()
@@ -228,7 +228,7 @@ def login(self, verbose: bool = True, auto_open_browser: bool = True) -> None:
228228
"""Perform interactive browser-based login.
229229
230230
Opens browser for OAuth2 device authorization flow with PKCE.
231-
Saves authentication tokens to ~/.amp-cli-config/amp_cli_auth.
231+
Saves authentication tokens to ~/.amp/cache/amp_cli_auth.
232232
233233
Args:
234234
verbose: Print progress messages
@@ -240,7 +240,7 @@ def login(self, verbose: bool = True, auto_open_browser: bool = True) -> None:
240240
Example:
241241
>>> auth = AuthService()
242242
>>> auth.login() # Opens browser for authentication
243-
>>> # Auth tokens saved to ~/.amp-cli-config/amp_cli_auth
243+
>>> # Auth tokens saved to ~/.amp/cache/amp_cli_auth
244244
"""
245245
from .device_flow import interactive_device_login
246246

src/amp/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ class Client:
272272
query_url: Query endpoint URL via Flight SQL (e.g., 'grpc://localhost:1602')
273273
admin_url: Optional Admin API URL (e.g., 'http://localhost:8080')
274274
auth_token: Optional Bearer token for authentication (highest priority)
275-
auth: If True, load auth token from ~/.amp-cli-config (shared with TS CLI)
275+
auth: If True, load auth token from ~/.amp/cache (shared with TS CLI)
276276
277277
Authentication Priority (highest to lowest):
278278
1. Explicit auth_token parameter
279279
2. AMP_AUTH_TOKEN environment variable
280-
3. auth=True - reads from ~/.amp-cli-config/amp_cli_auth
280+
3. auth=True - reads from ~/.amp/cache/amp_cli_auth
281281
282282
Example:
283283
>>> # Query-only client (backward compatible)
@@ -320,7 +320,7 @@ def get_token():
320320
def get_token():
321321
return env_token
322322
elif auth:
323-
# Priority 3: Load from ~/.amp-cli-config/amp_cli_auth (auto-refreshing)
323+
# Priority 3: Load from ~/.amp/cache/amp_cli_auth (auto-refreshing)
324324
from amp.auth import AuthService
325325

326326
auth_service = AuthService()

0 commit comments

Comments
 (0)