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

API Error - 401 Unauthorised #46

Open
CameronSmith93 opened this issue Nov 30, 2022 · 8 comments
Open

API Error - 401 Unauthorised #46

CameronSmith93 opened this issue Nov 30, 2022 · 8 comments

Comments

@CameronSmith93
Copy link

Hi there,

I just discovered this plugin today, and also created an OpenWeatherMap account at the same time, but it looks like my API key is being rejected:

[30/11/2022, 10:55:44] [Sprinklers] Error getting weather data or Response code 401 (Unauthorized) [30/11/2022, 10:56:45] [Sprinklers] Error getting weather data or Response code 401 (Unauthorized) [30/11/2022, 10:57:46] [Sprinklers] Error getting weather data or Response code 401 (Unauthorized) [30/11/2022, 10:58:46] [Sprinklers] Error getting weather data or Response code 401 (Unauthorized)

From what I've read in here, it appears there's a difference between v2.5 and v3.0 of the API - is there a setting I need to change in the config to get this working?

Thank you!

@AscendK2
Copy link

AscendK2 commented Nov 30, 2022 via email

@zilo85
Copy link

zilo85 commented Jan 29, 2023

Hi,
Have you been able to solve this problem. I am experiencing the same error.

I checked the API using the link
api.openweathermap.org/data/2.5/weather?q=peshawar&appid=API_key

everything looks correct"
{"coord":{"lon":xx.xxxx,"lat":xx.xxxx},"weather":[{"id":721,"main":"Haze","description":"haze","icon":"50d"},{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"base":"stations","main":{"temp":290.23,"feels_like":289.01,"temp_min":290.23,"temp_max":290.23,"pressure":1014,"humidity":39},"visibility":6000,"wind":{"speed":2.06,"deg":310},"rain":{"1h":0.16},"clouds":{"all":75},"dt":1674983442,"sys":{"type":1,"id":7590,"country":"PK","sunrise":1674958388,"sunset":1674996004},"timezone":18000,"id":1168197,"name":"Peshawar","cod":200}

Hi there,

I just discovered this plugin today, and also created an OpenWeatherMap account at the same time, but it looks like my API key is being rejected:

[30/11/2022, 10:55:44] [Sprinklers] Error getting weather data or Response code 401 (Unauthorized) [30/11/2022, 10:56:45] [Sprinklers] Error getting weather data or Response code 401 (Unauthorized) [30/11/2022, 10:57:46] [Sprinklers] Error getting weather data or Response code 401 (Unauthorized) [30/11/2022, 10:58:46] [Sprinklers] Error getting weather data or Response code 401 (Unauthorized)

From what I've read in here, it appears there's a difference between v2.5 and v3.0 of the API - is there a setting I need to change in the config to get this working?

Thank you!

@jmaferreira
Copy link

jmaferreira commented Mar 31, 2024

Be aware that:

One Call API 2.5 will be deprecated on April 15, 2024. Please read the detailed guide for transitioning to the more advanced One Call API 3.0 which includes several useful upgrades like 40+ years of history archive, daily aggregation and human readable daily summary in comparison with One Call API 2.5 version. Read more about One Call API 3.0 in the product documentation page and FAQ.

https://openweathermap.org/api/one-call-api

@jmaferreira
Copy link

jmaferreira commented Mar 31, 2024

BTW, this call works:

https://api.openweathermap.org/data/2.5/weather?lat=41,44205054070333&lon=-8,3115741152312&exclude=current,minutely,hourly,alerts&units=metric&appid=KEY

but this doesn't:

https://api.openweathermap.org/data/2.5/onecall?lat=41,44205054070333&lon=-8,3115741152312&exclude=current,minutely,hourly,alerts&units=metric&appid=KEY

/weather vs /onecall.

There is strong evidence that the onecall API for version 2.5 has been deprecated. Version 3.0 has a new payment scheme.

@Louison-B
Copy link

Louison-B commented Apr 13, 2024

Thank you for this wonderful plugin ! I subscribed to One Call API 3.0 https://openweathermap.org/api/one-call-3 and I modify /var/lib/homebridge/node_modules/homebridge-smart-irrigation/index.js this line : "const url = 'https://api.openweathermap.org/data/2.5/onecall?lat=' + this.latitude + '&lon=' + this.longitude + '&exclude=current,minutely,hourly>" in this "const url = 'https://api.openweathermap.org/data/3.0/onecall?lat=' + this.latitude + '&lon=' + this.longitude + '&exclude=current,minutely,hourly>" and now I haven't API Error - 401 Unauthorised ever.

Please make an update for other users.

Have a good day.

Louison.

@jmaferreira
Copy link

jmaferreira commented Apr 15, 2024

@Louison-B Can you submit a pull request?

@manuel140
Copy link

@jmaferreira here you go:
#65

Note: Users will have to add payment details to use v3.0 one call api.

@BL9PE
Copy link

BL9PE commented Jul 11, 2024

Hi All - can someone explain how I modify my install to use the new API 3.0 calls please? Everything else should be in place, including the OWM subscription & I can see the line (168) in the index.js file here on GitHub, but I can't find that file on my Pi to make the changes - I'm guessing its not that simple?

Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants