photogeek54 Posted July 7, 2023 Posted July 7, 2023 I'm getting an error 401 that my API key is incorrect but when I use the same key for a request like: api.openweathermap.org/data/2.5/weather?q=denver,us&appid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx It works fine. Is the "onecall" api not allowed for free accounts? Here' the log 2023-07-06 22:19:48,212 Thread-3 udi_interface DEBUG query:_get_weather_data: request = http://api.openweathermap.org/data/2.5/onecall?exclude=minutely,hourly& lat=40.585&lon=-105.084 &units=imperial&appid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2023-07-06 22:19:48,327 Thread-3 udi_interface DEBUG query:_get_weather_data: {'cod': 401, 'message': 'Invalid API key. Please see https://openweathermap.org/faq#error401 for more info.'} 2023-07-06 22:19:48,327 Thread-3 udi_interface ERROR query:query_onecall: Onecall data query failed
bpwwer Posted July 7, 2023 Posted July 7, 2023 12 hours ago, photogeek54 said: I'm getting an error 401 that my API key is incorrect but when I use the same key for a request like: api.openweathermap.org/data/2.5/weather?q=denver,us&appid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx It works fine. Is the "onecall" api not allowed for free accounts? 2023-07-06 22:19:48,327 Thread-3 udi_interface DEBUG query:_get_weather_data: {'cod': 401, 'message': 'Invalid API key. Please see https://openweathermap.org/faq#error401 for more info.'} Did you look at the FAQ and verify the checks they list there?
photogeek54 Posted July 8, 2023 Author Posted July 8, 2023 Yes I have reviewed the openweathermap FAQs multiple times. the node server creates the string for the API call, I can only set location, number of days, APIkey, etc. The API key was requested many days ago and works with a different API call. Supposedly a 5 day forecast is allowed by free accounts right?
bpwwer Posted July 8, 2023 Posted July 8, 2023 You can copy the URL from the log and paste it into a browser window to double check but there isn't anything the node server can do to make the API key be valid if the OpenWeatherMap server's say it isn't.
apostolakisl Posted July 8, 2023 Posted July 8, 2023 Open Weather has a 2.5 and 3.0 version. I know a 3.0 key does not work in 2.5. Not sure about the opposite. PG2 using 2.5, not sure what PG3 version uses.
bpwwer Posted July 8, 2023 Posted July 8, 2023 I'm pretty sure it's 3.0 as I believe the 2.5 api was supposed to have gone away years ago. However, when I go into my account, I can only generate a key, no choice for a 2.5 or 3.0 key
apostolakisl Posted July 9, 2023 Posted July 9, 2023 13 hours ago, bpwwer said: I'm pretty sure it's 3.0 as I believe the 2.5 api was supposed to have gone away years ago. However, when I go into my account, I can only generate a key, no choice for a 2.5 or 3.0 key I have PG2 on the ISY at my church and added openweather to it. I got a key from openweather and it didn't work (authentication error). I noticed that in the example openweather gives, everything is identical to the url PG2 openweather uses, except it shows 3.0 in the url where PG2 shows 2.5. So I cut and paste the url from the log in GP2 and loaded into a web browser. I got an error. I then changed the 2.5 in the url to 3.0 and it worked. I then used a key I have that is several years old from openweather and plugged it in using 2.5 and it worked. It appears that they have grandfathered in keys to keep working on 2.5. It also means unless you have an old key, PG2 won't work with openweather. Anyway, if the OP is using PG2 and a new key, it won't work. Perhaps, if he is using an old key and PG3 (which I assumes uses 3.0 in the url) it won't work. Or maybe it will, I haven't tried it that way.
photogeek54 Posted July 10, 2023 Author Posted July 10, 2023 Apparently currently generated API keys require a different API syntax The API documentation shows that for the free 5 day forecast the call can be "forecast" not "onecall" like below which works.https://api.openweathermap.org/data/2.5/forecast?lat=40.585&lon=-105.084&units=imperial&appid=xxxxxxxxxxxx without the exclude=minutely,hourly. The API call also works with the 2.5 replaced by 3.0 per below https://api.openweathermap.org/data/3.0/onecall?exclude=minutely,hourly&lat=40.585&lon=-105.084&units=imperial&appid=xxxxxxxxxxxxxxxxxxxxx
apostolakisl Posted July 10, 2023 Posted July 10, 2023 8 hours ago, photogeek54 said: Apparently currently generated API keys require a different API syntax The API documentation shows that for the free 5 day forecast the call can be "forecast" not "onecall" like below which works.https://api.openweathermap.org/data/2.5/forecast?lat=40.585&lon=-105.084&units=imperial&appid=xxxxxxxxxxxx without the exclude=minutely,hourly. The API call also works with the 2.5 replaced by 3.0 per below https://api.openweathermap.org/data/3.0/onecall?exclude=minutely,hourly&lat=40.585&lon=-105.084&units=imperial&appid=xxxxxxxxxxxxxxxxxxxxx The older version allows for free forecast more than 5 days. I forget the max, but I set mine to one week.
photogeek54 Posted July 11, 2023 Author Posted July 11, 2023 It just started working, maybe my API key finally got activated?
apostolakisl Posted July 14, 2023 Posted July 14, 2023 @photogeek54 I tried my key as well on Tuesday when you posted this and it didn't work. Then I tried it today, and it did work. I was able to use the 3.0 version very shortly after creating the key, but the 2.5 just started working now, after like 10 days or maybe more. 1
Recommended Posts