Closed giselleann closed 7 months ago
I also get a 401: Unauthorized
response from https://api.openweathermap.org/.
{
"cod": 401,
"message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."
}
But maybe this is just because we were too impatient. Because I just got an email saying:
Within the next couple of hours, it will be activated and ready to use
I'll leave this here FTR though.
Per #15, it takes a while for your key to be provisioned by them. If you need weather results sooner, I suggest ClimaCell.
@giselleann did you get it to work?
Having a similar problem. Not sure if i'm being impatient or if it's an actual age from OpenWeather's API.
Same issue. The API keys, old or new, are dismissed as 401: Unauthorized.
I've had my OpenWeather key for about 12 hours now and unfortunately I'm still getting "Error: 401 Unauthorized". How long do you have to be patient?
@miregal23 honestly, no idea. I recommend reaching out to OpenWeather to learn more.
Hi Jeff!
I solved the problem for myself in my own Python3 script. I use the following API call:
https://api.openweathermap.org/data/2.5/weather?q={city},{country code}&appid={my_api_key}&units=metric&lang=en"
Here I get the corresponding answer and I am satisfied. Maybe you can use this information for your Alfred workflow...
Greetings Oli Am 7. Sept. 2022, 21:24 +0200 schrieb Jeff Byrnes @.***>:
@miregal23 honestly, no idea. I recommend reaching out to OpenWeather to learn more. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
It seems that the current code uses the “One Call By Call” endpoint, which is only available when you provide billing information, but offers 1,000 free calls, as the OpenWeather Pricing page describes.
I’ll poke a little & see if I can make this work with the default free plan instead.
So I created a new API key, and while at first, it did not work, I came back a little later, and it works fine with the existing code.
Right now, the workflow makes calls like so:
♠ https "api.openweathermap.org/data/2.5/onecall?lat=42.394722&lon=-71.109103&appid=${API_KEY}"
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 20489
Content-Type: application/json; charset=utf-8
Date: Sun, 18 Sep 2022 17:22:35 GMT
Server: openresty
X-Cache-Key: /data/2.5/onecall?lat=42.39&lon=-71.11
[snip]
I’ve set up the workflow using this new API key of mine, and toggling it to use OpenWeather for its API, and the workflow works well.
So I can’t reproduce this, unfortunately.
Here is a small excerpt from the Alfred debugger: It also doesn't work with a specially created API key from openweather...not even after 12 hours....
[weather] 2022/09/19 06:58:40 getting forecast for main.Location{Latitude:40.7127281, Longitude:-74.0060152, ShortName:"City of New York, New York, United States", Name:"City of New York, New York, United States"} [weather] 2022/09/19 06:58:40 getting URL https://api.openweathermap.org/data/2.5/onecall?appid={API_KEY}&lat=40.712728&lon=-74.006015&units=metric [alfred] 2022/09/19 06:58:40 loaded cache [alfred] 2022/09/19 06:58:40 Error: 401 Unauthorized [06:58:40.793] Weather[Script Filter] {"items":[{"title":"Error: 401 Unauthorized","arg":"{}","valid":false}]}
Not sure what to tell you, @miregal23.
Some “dumb” questions to be sure you’ve got things configured properly:
wto
into Alfred?Mine is working well with OpenWeather at this point:
[10:19:39.368] Weather[Script Filter] {"items":[{"title":"Refreshed!","subtitle":"Data will be reloaded on the next forecast","arg":"{}","valid":false}]}
[10:19:45.847] Weather[Script Filter] Queuing argument ''
[10:19:46.450] Weather[Script Filter] Script with argv '' finished
[10:19:46.459] STDERR: Weather[Script Filter] [alfred] 2022/09/19 10:19:45 Alfred version: 5.0.2
[weather] 2022/09/19 10:19:45 Using config file /Users/jeffbyrnes/Library/Application Support/Alfred/Workflow Data/com.jason0x43.alfred-weather/config.json
[weather] 2022/09/19 10:19:45 Using cache file /Users/jeffbyrnes/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.jason0x43.alfred-weather/cache.json
[weather] 2022/09/19 10:19:45 loaded config
[weather] 2022/09/19 10:19:45 loaded cache
[alfred] 2022/09/19 10:19:45 set keyword to 'daily'
[alfred] 2022/09/19 10:19:45 tell: data=alfred.workflowData{Keyword:"daily", Mode:"tell", Mod:"", Data:""}, arg=''
[alfred] 2022/09/19 10:19:45 Adding items for 'daily'
[weather] 2022/09/19 10:19:45 Running DailyCommand
[weather] 2022/09/19 10:19:45 using configured location
[weather] 2022/09/19 10:19:45 getting forecast for main.Location{Latitude:42.39031035304344, Longitude:-71.08542360028589, ShortName:"Somerville, Middlesex County, Massachusetts, 02145, United States", Name:"Somerville, Middlesex County, Massachusetts, 02145, United States"}
[weather] 2022/09/19 10:19:45 getting URL https://api.openweathermap.org/data/2.5/onecall?appid=${API_KEY}&lat=42.390310&lon=-71.085424&units=metric
[alfred] 2022/09/19 10:19:46 Saving JSON to /Users/jeffbyrnes/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.jason0x43.alfred-weather/cache.json
[weather] 2022/09/19 10:19:46 precip: -1
[weather] 2022/09/19 10:19:46 precip: -1
[weather] 2022/09/19 10:19:46 precip: -1
[weather] 2022/09/19 10:19:46 precip: -1
[weather] 2022/09/19 10:19:46 precip: -1
[weather] 2022/09/19 10:19:46 precip: -1
[weather] 2022/09/19 10:19:46 precip: -1
[weather] 2022/09/19 10:19:46 precip: -1
[alfred] 2022/09/19 10:19:46 loaded cache
[10:19:46.460] Weather[Script Filter] {"items":[{"title":"Weather for Somerville, Middlesex County, Massachusetts, 02145, United States","subtitle":"–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––","arg":"{}","valid":false,"mods":{"cmd":{"arg":"{\"keyword\":\"daily\",\"mode\":\"do\",\"mod\":\"cmd\",\"data\":\"{\\\"ToOpen\\\":\\\"https://api.openweathermap.org/data/2.5/onecall?lat=42.390310\\\\u0026lon=-71.085424\\\\u0026units=metric\\\"}\"}","valid":true,"subtitle":"Open this forecast in a browser"}}},{"title":"Currently: overcast clouds","subtitle":"61°F (61°F)","arg":"{\"keyword\":\"hourly\",\"mode\":\"tell\",\"data\":\"{\\\"Start\\\":\\\"0001-01-01T00:00:00Z\\\"}\"}","icon":{"path":"icons/grzanka/mostlycloudy.png"},"valid":true},{"title":"Today: heavy intensity rain","subtitle":"↓ 61°F ↑ 70°F ☼ 06:28 ☾ 18:47","arg":"{\"keyword\":\"hourly\",\"mode\":\"tell\",\"data\":\"{\\\"Start\\\":\\\"2022-09-19T06:28:29-04:00\\\"}\"}","icon":{"path":"icons/grzanka/rain.png"},"valid":true},{"title":"Tuesday: light rain","subtitle":"↓ 57°F ↑ 62°F ☼ 06:29 ☾ 18:46","arg":"{\"keyword\":\"hourly\",\"mode\":\"tell\",\"data\":\"{\\\"Start\\\":\\\"2022-09-20T06:29:32-04:00\\\"}\"}","icon":{"path":"icons/grzanka/rain.png"},"valid":true},{"title":"Wednesday: overcast clouds","subtitle":"↓ 55°F ↑ 71°F ☼ 06:30 ☾ 18:44","arg":"{\"keyword\":\"hourly\",\"mode\":\"tell\",\"data\":\"{\\\"Start\\\":\\\"2022-09-21T06:30:35-04:00\\\"}\"}","icon":{"path":"icons/grzanka/mostlycloudy.png"},"valid":true},{"title":"Thursday: light rain","subtitle":"↓ 51°F ↑ 69°F ☼ 06:31 ☾ 18:42","arg":"{}","icon":{"path":"icons/grzanka/rain.png"},"valid":false},{"title":"Friday: broken clouds","subtitle":"↓ 48°F ↑ 58°F ☼ 06:32 ☾ 18:40","arg":"{}","icon":{"path":"icons/grzanka/mostlycloudy.png"},"valid":false},{"title":"Saturday: broken clouds","subtitle":"↓ 45°F ↑ 64°F ☼ 06:33 ☾ 18:38","arg":"{}","icon":{"path":"icons/grzanka/mostlycloudy.png"},"valid":false},{"title":"Sunday: broken clouds","subtitle":"↓ 49°F ↑ 73°F ☼ 06:34 ☾ 18:37","arg":"{}","icon":{"path":"icons/grzanka/mostlycloudy.png"},"valid":false},{"title":"Monday: moderate rain","subtitle":"↓ 60°F ↑ 68°F ☼ 06:35 ☾ 18:35","arg":"{}","icon":{"path":"icons/grzanka/rain.png"},"valid":false}]}
The problem is that the new api they use is 3.0 and it seems the project is using /data/2.5/onecall
instead of data/3.0/xyz
I don't think there's a way to get the a key to the old 2.5 API
The problem is that the new api they use is 3.0 and it seems the project is using
/data/2.5/onecall
instead ofdata/3.0/xyz
I don't think there's a way to get the a key to the old 2.5 API
That sounds plausible to me. One of the developers would have to create a "new" account at Openweather and then create a "new" API key here. The workflow should no longer work with this key. Then you would know where we stand...
I ran into key problems this morning. My key wasn't working (it had been quite a while since I used OpenWeather). I subscribed to their OneCall plan, which appears to be a requirement now. After subscribing, my key still didn't immediately work, so I created new key, which also didn't immediately work. After half an hour or so, the new key did start working. So:
I set it up and added Open weather API Key but it's giving me an Error 404: Unauthorized message.
Thanks!