-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_bg_levels.py
executable file
·48 lines (36 loc) · 1.2 KB
/
get_bg_levels.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
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
import requests
import sys
# Example program, printing last 10 bg levels.
# Run with `python3 <program> <Dexcom username> <Dexcom password>`.
# https://github.com/StephenBlackWasAlreadyTaken/xDrip/issues/182
APPLICATION_ID = "d89443d2-327c-4a6f-89e5-496bbb0317db"
username = sys.argv[1]
password = sys.argv[2]
account_id_response = requests.request(
"POST",
"https://shareous1.dexcom.com/ShareWebServices/Services/General/AuthenticatePublisherAccount",
json={
"accountName": username,
"password": password,
"applicationId": APPLICATION_ID,
},
)
account_id = account_id_response.json()
print(account_id)
session_id_response = requests.request(
"POST",
"https://shareous1.dexcom.com/ShareWebServices/Services/General/LoginPublisherAccountById",
json={
"accountId": account_id,
"password": password,
"applicationId": APPLICATION_ID,
},
)
session_id = session_id_response.json()
print(session_id)
bg_data = requests.request(
"POST",
f"https://shareous1.dexcom.com/ShareWebServices/Services/Publisher/ReadPublisherLatestGlucoseValues?sessionId={session_id}&minutes=1440&maxCount=10",
)
print(bg_data.json())