Local and cloud-based workflows for extracting and updating text layers in PSD files via ExtendScript and Adobe PS API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
91 lines
No EOL
3.6 KiB
Python
91 lines
No EOL
3.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Direct test of Adobe API with a hard-coded token
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import json
|
|
import requests
|
|
|
|
# Hard-coded token for testing
|
|
ACCESS_TOKEN = "eyJhbGciOiJSUzI1NiIsIng1dSI6Imltc19uYTEta2V5LWF0LTEuY2VyIiwia2lkIjoiaW1zX25hMS1rZXktYXQtMSIsIml0dCI6ImF0In0.eyJpZCI6IjE3NDQ4NzYzNDM5MzdfNTE1YjU0NTgtZDU3NC00N2RlLThmNzgtYjQ5MGMwYjZiOWYyX3VlMSIsIm9yZyI6IkZBRDYxRTI3NjY4NkRCM0QwQTQ5NUVDNEBBZG9iZU9yZyIsInR5cGUiOiJhY2Nlc3NfdG9rZW4iLCJjbGllbnRfaWQiOiJmMzRiZWNiNzU5MjQ0ODk5YmQ3M2I4NjIyMGY2ZmI5MiIsInVzZXJfaWQiOiJEQTM3MUY1NzY3RUJEMDdEMEE0OTVGOTRAdGVjaGFjY3QuYWRvYmUuY29tIiwiYXMiOiJpbXMtbmExIiwiYWFfaWQiOiJEQTM3MUY1NzY3RUJEMDdEMEE0OTVGOTRAdGVjaGFjY3QuYWRvYmUuY29tIiwiY3RwIjozLCJtb2kiOiIzMDA1NWZlNyIsImV4cGlyZXNfaW4iOiI4NjQwMDAwMCIsImNyZWF0ZWRfYXQiOiIxNzQ0ODc2MzQzOTM3Iiwic2NvcGUiOiJvcGVuaWQsQWRvYmVJRCxyZWFkX29yZ2FuaXphdGlvbnMifQ.GzwaTJU1BrGBt0JIlH8_RGvGcF8qwmmbGSsLaQ-3QcXnU-79WE6iHbgI4U3yQ14DcLOUZz0WX1rJ0Hve7Yysa2jAJBSu7bP3ELMWGTQVDLf0yvRr0oG2LCh4BwA3hdh-dNiAOKfRCLMHCyPtDdaU3EfLQ0OUm3_LgZR9oi80q_H7uLLHifnUTrsMt5zS3S5rYLQhkQEIEQbY1KRoqKmzuKv8MbsU5YpuoN_HZWn4eOuF6dTv1pSk2EkKUzXzwMJHBjCfJohXnXiO7m_YlHfp1DLI3OcBuxEb4JkRLmyTDxPrwuuBYVXIEpM-1ER0dxsWMmJXlz6bEuRBpJLyPWfD1ldFh3bEMaa0YA"
|
|
API_KEY = "f34becb759244899bd73b86220f6fb92"
|
|
|
|
def test_authentication():
|
|
"""Test token authentication directly"""
|
|
print(f"\nTesting Adobe API authentication with token")
|
|
|
|
# Prepare headers with token
|
|
headers = {
|
|
"Authorization": f"Bearer {ACCESS_TOKEN}"
|
|
}
|
|
|
|
# Make the request to validate the token
|
|
try:
|
|
response = requests.get(
|
|
"https://ims-na1.adobelogin.com/ims/userinfo",
|
|
headers=headers,
|
|
timeout=20
|
|
)
|
|
|
|
print(f"Authentication response status: {response.status_code}")
|
|
|
|
if response.text:
|
|
try:
|
|
user_info = response.json()
|
|
print(f"Response JSON: {json.dumps(user_info, indent=2)}")
|
|
except:
|
|
print(f"Response text: {response.text}")
|
|
|
|
return response.status_code == 200
|
|
except Exception as e:
|
|
print(f"Error testing authentication: {str(e)}")
|
|
return False
|
|
|
|
def test_text_edit_endpoint():
|
|
"""Test the text edit endpoint directly"""
|
|
print(f"\nTesting Adobe Photoshop text editing API")
|
|
|
|
# Prepare headers
|
|
headers = {
|
|
"x-api-key": API_KEY,
|
|
"Authorization": f"Bearer {ACCESS_TOKEN}",
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
# Test endpoints
|
|
endpoints = [
|
|
"https://firefly-api.adobe.io/v2/photoshop/editText",
|
|
"https://image.adobe.io/pie/psdService/text"
|
|
]
|
|
|
|
for endpoint in endpoints:
|
|
print(f"\nTesting endpoint: {endpoint}")
|
|
|
|
# Make a simple GET request first
|
|
try:
|
|
get_response = requests.get(
|
|
endpoint,
|
|
headers=headers,
|
|
timeout=10
|
|
)
|
|
|
|
print(f"GET response status: {get_response.status_code}")
|
|
|
|
if get_response.text:
|
|
try:
|
|
resp_json = get_response.json()
|
|
print(f"GET response JSON: {json.dumps(resp_json, indent=2)}")
|
|
except:
|
|
print(f"GET response text: {get_response.text[:500]}")
|
|
except Exception as e:
|
|
print(f"Error making GET request: {str(e)}")
|
|
|
|
if __name__ == "__main__":
|
|
# Test authentication
|
|
auth_success = test_authentication()
|
|
print(f"\nAuthentication test {'passed' if auth_success else 'failed'}")
|
|
|
|
# Test text edit endpoint
|
|
test_text_edit_endpoint() |