From 766986a79571ac96ba4268dc733cc8d5581c0a10 Mon Sep 17 00:00:00 2001 From: Paul Huliganga Date: Thu, 16 Apr 2026 10:10:05 -0400 Subject: [PATCH] refactor: rename auth_adobe.py to adobe_auth.py for naming consistency Matches the naming convention of docusign_auth.py. Update all references in README.md and the error message in adobe_api.py. Co-Authored-By: Claude Sonnet 4.6 --- README.md | 4 ++-- src/{auth_adobe.py => adobe_auth.py} | 31 +++++++++++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) rename src/{auth_adobe.py => adobe_auth.py} (71%) diff --git a/README.md b/README.md index 95c4138..c997d42 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ For production replace with `account.docusign.com` and your account's base URL ( **3. Authenticate with Adobe Sign** (one-time): ```bash -python3 src/auth_adobe.py +python3 src/adobe_auth.py ``` Opens a browser. After authorizing, paste the redirect URL back into the terminal. Tokens are saved to `.env` and auto-refreshed on subsequent runs. @@ -120,7 +120,7 @@ unexpected API behaviors, and the fixes applied. ``` src/ - auth_adobe.py # One-time OAuth flow for Adobe Sign + adobe_auth.py # One-time OAuth flow for Adobe Sign adobe_api.py # Adobe Sign API client (auto token refresh) download_templates.py # List and download templates from Adobe Sign compose_docusign_template.py # Core conversion: Adobe Sign → DocuSign JSON diff --git a/src/auth_adobe.py b/src/adobe_auth.py similarity index 71% rename from src/auth_adobe.py rename to src/adobe_auth.py index 75d7b45..b51661f 100644 --- a/src/auth_adobe.py +++ b/src/adobe_auth.py @@ -2,7 +2,7 @@ One-time Adobe Sign OAuth setup. Run this script once to authorize the app and save tokens to .env: - python src/auth_adobe.py + python src/adobe_auth.py Prerequisites: - Set ADOBE_CLIENT_ID and ADOBE_CLIENT_SECRET in .env (or export them) @@ -58,17 +58,34 @@ def exchange_code_for_tokens(code, client_id, client_secret): "client_secret": client_secret, } resp = requests.post(TOKEN_URL, data=data) - resp.raise_for_status() - return resp.json() + if not resp.ok: + print(f"ERROR: Token exchange failed ({resp.status_code}): {resp.text}") + resp.raise_for_status() + tokens = resp.json() + print(f"Token exchange response keys: {list(tokens.keys())}") + if "error" in tokens: + raise ValueError(f"Adobe Sign returned error: {tokens.get('error')}: {tokens.get('error_description')}") + return tokens def save_tokens(tokens): + access_token = tokens.get("access_token", "") + refresh_token = tokens.get("refresh_token", "") + + if not access_token: + raise ValueError("Adobe Sign did not return an access_token — not saving incomplete tokens") + if not refresh_token: + print("WARNING: Adobe Sign did not return a refresh_token — you will need to re-authenticate when the access token expires (~1 hour)") + abs_env = os.path.abspath(ENV_FILE) - set_key(abs_env, "ADOBE_ACCESS_TOKEN", tokens["access_token"]) - if "refresh_token" in tokens: - set_key(abs_env, "ADOBE_REFRESH_TOKEN", tokens["refresh_token"]) + set_key(abs_env, "ADOBE_ACCESS_TOKEN", access_token) + if refresh_token: + set_key(abs_env, "ADOBE_REFRESH_TOKEN", refresh_token) set_key(abs_env, "ADOBE_SIGN_BASE_URL", f"https://api.{SHARD}.adobesign.com/api/rest/v6") - print(f"Tokens saved to {abs_env}") + print(f"Access token saved (length={len(access_token)})") + if refresh_token: + print(f"Refresh token saved (length={len(refresh_token)})") + print(f"Tokens written to {abs_env}") def main():