Jump to content

Invalid API key


Recommended Posts

 
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
Link to comment

 

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?

Link to comment

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?

Link to comment

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.

Link to comment

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

Link to comment
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.

Link to comment

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 

Link to comment
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.

Link to comment
Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      36.9k
    • Total Posts
      370.2k
×
×
  • Create New...