Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Invalid API key

Featured Replies

Posted
 
I'm getting an error 401 that my API key is incorrect but when I use the same key for a request like:
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

 

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:
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?

  • Author

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?

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.

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.

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

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.

  • Author

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 

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.

  • Author

It just started working, maybe my API key finally got activated?

@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.

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.