-
Notifications
You must be signed in to change notification settings - Fork 11
/
get_accesstoken.py
39 lines (33 loc) · 1.08 KB
/
get_accesstoken.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import requests
import secret
def getAccessToken():
URL = "https://restapimoonboard.ems-x.com/token"
headers = {
'accept-encoding': 'gzip, gzip',
'content-type': 'application/x-www-form-urlencoded',
'host': 'restapimoonboard.ems-x.com',
'user-agent': 'MoonBoard/1.0',
}
data = {
'refresh_token': getRefreshToken(),
'grant_type': 'refresh_token',
'client_id': 'com.moonclimbing.mb'
}
r = requests.get(URL, headers=headers, data=data)
return r.json()['access_token']
def getRefreshToken():
URL = "https://restapimoonboard.ems-x.com/token"
headers = {
'accept-encoding': 'gzip, gzip',
'content-type': 'application/x-www-form-urlencoded',
'host': 'restapimoonboard.ems-x.com',
'user-agent': 'MoonBoard/1.0',
}
data = {
'username': secret.username,
'password': secret.password,
'grant_type': 'password',
'client_id': 'com.moonclimbing.mb'
}
r = requests.get(URL, headers=headers, data=data)
return(r.json()['refresh_token'])