i just wanted to play with the energy meter data but the message is Invalid user token why is it so following is the code
import json
import requests
# Load the configuration file
with open(r'D:\Notes\7th_Sem\Final_Year_Project\API Iammeter\config.json') as config_file:
config = json.load(config_file)
# API key
api_key = config['API_KEY']
# headers
headers = {
"Authorization": f"Bearer {api_key}"
}
# API request
url = "https://www.iammeter.com/api/v1/site/metersdata"
response = requests.get(url, headers=headers)
data = response.json()
print(data)
Please refer to https://www.iammeter.com/docs/system-api#account-get-the-token-of-the-account
Please note, the token does not need to be refreshed every time ,it can be always used until it expire .