[SOLVED] API 401/403 Access error

Apologies upfront if this shows my lack of python or API skills.

I am trying to download an activity

  • When I replace ATHLETE_ID with my athlete_id I do get a 403 Access Denied error
  • When I replace ATHLETE_ID with “0” I do get a 402 - Unauthorized erorr
  • API_KEY is the key from my settings page

URL = f"https://intervals.icu/api/v1/athlete/{ATHLETE_ID}/activities"

headers = {
“Authorization”: f"Bearer {API_KEY}",
“Content-Type”: “application/json”,
}

response = requests.get(URL, headers=headers)
if response.status_code == 200:
activities = response.json()

print(f"{response.status_code} - {response.text}")

You need to use Basic auth, not Bearer.

2 Likes

Much thanks! That worked!