Files
Srilekha 78a46a8dbe
HIFFI Multi-Platform CI / test (3.12) (push) Successful in 50s
HIFFI Multi-Platform CI / test (3.11) (push) Successful in 50s
feat: finalize root api.py with X-Auth-Secret auth security and clean pure sales cohort
2026-11-04 16:49:39 +05:30

34 lines
1.1 KiB
Python

"""
Manual diagnostic utility for testing public and authenticated Spotify API endpoints.
Excluded from automated pytest discovery.
"""
import os
from pathlib import Path
import requests
__test__ = False
def run_manual_endpoint_test(token: str):
"""Manual probe for validating token scopes against official Spotify Web API endpoints."""
headers = {"Authorization": f"Bearer {token}"}
sample_id = "06HL4z0CvFAxyc27GXpf02" # Taylor Swift
url = f"https://api.spotify.com/v1/artists/{sample_id}"
resp = requests.get(url, headers=headers, timeout=10)
print(f"Status Code: {resp.status_code}")
if resp.status_code == 200:
data = resp.json()
print(f"Artist Name: {data.get('name')}")
print(f"Followers: {data.get('followers', {}).get('total')}")
else:
print(f"Error Payload: {resp.text}")
if __name__ == "__main__":
test_token = os.getenv("SPOTIFY_ACCESS_TOKEN", "").strip()
if not test_token:
print("Usage: Set SPOTIFY_ACCESS_TOKEN in environment before executing.")
else:
run_manual_endpoint_test(test_token)