Skip to content

Commit 28528bc

Browse files
Wrote code for the get weather portion, but receiving a 500 HTTP response so need to debug.
1 parent 7c75e29 commit 28528bc

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

code/zach/mini-capstone.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,26 @@ def create_key(signature_alg, key_id, team_id, service_id, iat, key_path):
1717
payload = {
1818
"iss": team_id,
1919
"iat": iat,
20-
"exp": iat + 100,
20+
"exp": iat + 3600,
2121
"sub": service_id
2222
}
2323

2424
s = jwt.encode(header, payload, key)
2525

2626
return s
2727

28-
def get_weather(language='en', latitude=0, longitude=0, web_token):
29-
response = requests.get(f"https://weatherkit.apple.com/api/v1/weather/{language}/{latitude}/{longitude}", params={
30-
'Authorization': f'Bearer {web_token}'
28+
def get_weather(language, latitude, longitude, web_token, timezone):
29+
response = requests.get(f"https://weatherkit.apple.com/api/v1/weather/{language}/{latitude}/{longitude}", headers = {
30+
'Authorization': f'Bearer {web_token}',
31+
'Accept': 'application/json'
32+
},
33+
params = {
34+
'timezone': timezone,
35+
'dataSets': 'currentWeather'
3136
})
32-
print(response.json())
37+
print(response)
38+
#current_weather = response.json()
39+
#return current_weather
3340

3441
def main():
3542
web_token = create_key("ES256",
@@ -40,7 +47,6 @@ def main():
4047
"C:/Users/zacha/OneDrive/Coding/Keys/Home_Dashboard/WeatherKit/AuthKey_74B4NT7KNA.p8"
4148
)
4249

43-
44-
50+
get_weather('en', 38.933868, -77.177261, web_token, 'America/New_York')
4551

4652
main()

0 commit comments

Comments
 (0)