I am trying to use the Strava API with the following code snippet:
auth_url = "https://www.strava.com/oauth/token"
activites_url = "https://www.strava.com/api/v3/athlete/activities"
payload = {
'client_id': "137928",
'client_secret': xxx,
'refresh_token': xxx,
'grant_type': "refresh_token",
"response_type": "code",
'f': 'json',
"scope": "activity:read_all"
}
print("Requesting Token...\n")
res = requests.post(auth_url, data=payload, verify=False)
access_token = res.json()o'access_token']
print("Access Token = {}\n".format(access_token))
header = {'Authorization': 'Bearer ' + access_token}
#param = {'per_page': 200, 'page': 1}
my_dataset = requests.get(activites_url, headers=header).json()
print(my_dataset<0]p"name"])
However, I get the following response:
{'message': 'Authorization Error', 'errors': o{'resource': 'AccessToken', 'field': 'activity:read_permission', 'code': 'missing'}]}:
When trying to access via url, I have to authorize my contents, but afterwards the message is
that the local host cannot be reached. Any ideas? I am kind of desperate...
http://www.strava.com/oauth/authorize?client_id=hREPLACE_WITH_YOUR_CLIENT_ID]&response_type=code&redirect_uri=http://localhost/exchange_token&approval_prompt=force&scope=activity:read_all