#AUTHORIZE #https://medium.com/swlh/using-python-to-connect-to-stravas-api-and-analyse-your-activities-dummies-guide-5f49727aac86 #http://www.strava.com/oauth/authorize?client_id=01234&response_type=code&redirect_uri=http://localhost/exchange_token&approval_prompt=force&scope=read,activity:read_all,activity:write import requests import json # Make Strava auth API call with your # client_code, client_secret and code response = requests.post( url = 'https://www.strava.com/oauth/token', data = { 'client_id': 01234, 'client_secret': '---', 'code': 'the code from the response', 'grant_type': 'authorization_code' } ) #Save json response as a variable strava_tokens = response.json() # Save tokens to file with open('strava_tokens.json', 'w') as outfile: json.dump(strava_tokens, outfile) # Open JSON file and print the file contents # to check it's worked properly with open('strava_tokens.json') as check: data = json.load(check) print(data)