Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New OpenWheater integration with "Invalid API Key" #76877

Closed
nbranquinho opened this issue Aug 16, 2022 · 11 comments
Closed

New OpenWheater integration with "Invalid API Key" #76877

nbranquinho opened this issue Aug 16, 2022 · 11 comments

Comments

@nbranquinho
Copy link

The problem

Last night I registered with OPENWheater to have access to the API key to integrate into HA, however, and after more than 12 hours, I still get the error that the API Key is invalid when it is actually working (I tested from the link I received by email).

At the level of logs I don't see anything associated with this situation.

What version of Home Assistant Core has the issue?

Operating System 8.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

openwheatermap

Link to integration documentation on our website

https://www.home-assistant.io/integrations/openweathermap/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@probot-home-assistant
Copy link

openweathermap documentation
openweathermap source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @fabaff, @freekode, @nzapponi, mind taking a look at this issue as it has been labeled with an integration (openweathermap) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@drmmerguy84
Copy link

I'm having the same issue. Pretty sure my API is active on openweather's end as I can manually enter it in the url and receive text weather data back.

@nickrout
Copy link

There is a comment on the forum that this may be related to an openweathermap api update https://community.home-assistant.io/t/cannot-setup-openweathermap/450817/2?u=nickrout

@Charlio99
Copy link

I'm having the same issue. Any news?

@warlordattack
Copy link

same issue here :

my api key gives data :
http://api.openweathermap.org/data/2.5/weather?q=London,uk&APPID=41f3a203873be028f51f000677f9ef26

but when registering integration there is an error :

2022-08-18_143953

@jafoobari
Copy link

I'm having the exact same issue. And I have verified that my API key is working by making a successful request separately from HA:

http://api.openweathermap.org/data/3.0/onecall?lat=45&lon=-105&exclude=minutely,daily&units=imperial&appid=*******1ce8

@nickrout
Copy link

@jallen92 Please read the thread post I pointed to, you will see why accessing the 3.0 api is irrelevant.

@jafoobari
Copy link

jafoobari commented Aug 19, 2022

Ah yup, thanks, @nickrout ! I wish I read that first before investigating on my own 🤦 . I came to the same conclusion. I'll summarize here for others since I already wrote this up:

  • The HA OWM integration relies on the pyowm module.

  • The pyowm module is using the 2.5 version of the OWM API which has been deprecated by OWM for their 3.0 version of their API.

  • So pyowm is attempting to make API requests with this kind of URL, /data/2.5/onecall , instead of /data/3.0/onecall.

  • There's an open issue on the pyowm repo for this: openweathermap deprecating 2.5 APIs csparpa/pyowm#404.

  • This issue will remain until the pyowm module is updated to properly use the 3.0 version of the API or the HA OWM integration adds some workaround code that just alters the request URL to use "3.0" instead of "2.5".

  • If curious, you can replicate the exact error by simply switching out "3.0" for "2.5" in your own OWM API request that you send in your web browser, terminal, or favorite API GUI client. Example below:

> GET /data/3.0/onecall?lat=45&lon=105&appid=<REDACTED> HTTP/1.1
> Host: api.openweathermap.org
> User-Agent: insomnia/2022.5.1
> Accept: */*


< HTTP/1.1 200 OK
< Server: openresty
< Date: Fri, 19 Aug 2022 19:48:06 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 19755
< Connection: keep-alive
< X-Cache-Key: /data/3.0/onecall?lat=45&lon=105
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET, POST

{"lat":45,"lon":105,"timezone":"Asia/Ulaanbaatar","timezone_offset":28800,"current":...>

vs.

> GET /data/2.5/onecall?lat=45&lon=105&appid=<REDACTED> HTTP/1.1
> Host: api.openweathermap.org
> User-Agent: insomnia/2022.5.1
> Accept: */*

< HTTP/1.1 401 Unauthorized
< Server: openresty
< Date: Fri, 19 Aug 2022 19:48:37 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 107
< Connection: keep-alive
< X-Cache-Key: /data/2.5/onecall?lat=45&lon=105
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET, POST

{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}

@nbranquinho
Copy link
Author

nbranquinho commented Aug 30, 2022

Ah yup, thanks, @nickrout ! I wish I read that first before investigating on my own 🤦 . I came to the same conclusion. I'll summarize here for others since I already wrote this up:

  • The HA OWM integration relies on the pyowm module.
  • The pyowm module is using the 2.5 version of the OWM API which has been deprecated by OWM for their 3.0 version of their API.
  • So pyowm is attempting to make API requests with this kind of URL, /data/2.5/onecall , instead of /data/3.0/onecall.
  • There's an open issue on the pyowm repo for this: openweathermap deprecating 2.5 APIs csparpa/pyowm#404.
  • This issue will remain until the pyowm module is updated to properly use the 3.0 version of the API or the HA OWM integration adds some workaround code that just alters the request URL to use "3.0" instead of "2.5".
  • If curious, you can replicate the exact error by simply switching out "3.0" for "2.5" in your own OWM API request that you send in your web browser, terminal, or favorite API GUI client. Example below:
> GET /data/3.0/onecall?lat=45&lon=105&appid=<REDACTED> HTTP/1.1
> Host: api.openweathermap.org
> User-Agent: insomnia/2022.5.1
> Accept: */*


< HTTP/1.1 200 OK
< Server: openresty
< Date: Fri, 19 Aug 2022 19:48:06 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 19755
< Connection: keep-alive
< X-Cache-Key: /data/3.0/onecall?lat=45&lon=105
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET, POST

{"lat":45,"lon":105,"timezone":"Asia/Ulaanbaatar","timezone_offset":28800,"current":...>

vs.

> GET /data/2.5/onecall?lat=45&lon=105&appid=<REDACTED> HTTP/1.1
> Host: api.openweathermap.org
> User-Agent: insomnia/2022.5.1
> Accept: */*

< HTTP/1.1 401 Unauthorized
< Server: openresty
< Date: Fri, 19 Aug 2022 19:48:37 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 107
< Connection: keep-alive
< X-Cache-Key: /data/2.5/onecall?lat=45&lon=105
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET, POST

{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}

Interesting....
My API Key only works well with 2.5... In 3.0 I got error "Internal error".... (when called from the browser)

@jbouwh
Copy link
Contributor

jbouwh commented Sep 9, 2022

I am closing this issue now. The documentation has been updated to explain that only the hourly mode works. If you still have an error, setup the entry again. Make sure you have at least HA 2022.9.1

@jbouwh jbouwh closed this as completed Sep 9, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants