-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.py
24 lines (22 loc) · 808 Bytes
/
auth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests
import json
from keys import CLIENT_ID, CLIENT_SECRET, CLIENT_CODE
response = requests.post(
url = 'https://www.strava.com/oauth/token',
data = {
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'code': CLIENT_CODE,
'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)