-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest1.py
More file actions
21 lines (18 loc) · 756 Bytes
/
Copy pathtest1.py
File metadata and controls
21 lines (18 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import requests
def get_ecobee_access_token(api_key, refresh_token):
url = "https://api.ecobee.com/token"
payload = {
'grant_type': 'refresh_token',
'refresh_token': refresh_token,
'client_id': api_key
}
response = requests.post(url, params=payload)
if response.status_code == 200:
return response.json() # This will return the access token and a new refresh token
else:
return response.json() # This will contain error information
# Replace 'your_api_key' and 'your_refresh_token' with your actual ecobee API key and refresh token
api_key = 'your_api_key'
refresh_token = 'your_refresh_token'
access_token_info = get_ecobee_access_token(api_key, refresh_token)
print(access_token_info)