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

I got API by register but not work error: Invalid API key #46

Closed
munkh-altai opened this issue Oct 10, 2015 · 50 comments
Closed

I got API by register but not work error: Invalid API key #46

munkh-altai opened this issue Oct 10, 2015 · 50 comments
Labels

Comments

@munkh-altai
Copy link

I got api by free register and i added my api to $weather = $owm->getWeather('Berlin', $units, $lang, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); xxxxxxx is my api but i got error

OpenWeatherMap exception: Unknown fatal error: OpenWeatherMap returned the following json object: Invalid API key. Please see http://openweathermap.org/faq#error401 for more info. (Code 0).

@cmfcmf
Copy link
Owner

cmfcmf commented Oct 12, 2015

For everyone reading this in the future: It can take "a couple of hours" until your API key is activated (see https://openweathermap.org/faq#error401).


Hi @altaihero, does calling the following URL in your browser work for you (replace the X's by your api key)?

http://api.openweathermap.org/data/2.5/weather?q=Berlin&APPID=XXXXXXXXXXXXXXXXXXXXXXXX

@munkh-altai
Copy link
Author

Hi @cmfcmf i was't use xxxx in APPID xxxx is just example.
But I it is fine working today.

@cmfcmf
Copy link
Owner

cmfcmf commented Oct 18, 2015

Ok cool!

@marlonlom
Copy link

at now, it continue just like that...
{ cod: 401, message: "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info." }

@cmfcmf
Copy link
Owner

cmfcmf commented Apr 20, 2016

Hi @marlonlom!

Does the problem persist? Does calling http://api.openweathermap.org/data/2.5/weather?q=Berlin&APPID=XXXXXXXXXXXXXXXXXXXXXXXX directly from your browser work?
Please note that it takes a few minutes until your new api key is activated.

Let me know if it works now!

@georgeharnwell
Copy link

Hi @cmfcmf,

I am now having this issue. I can successfully navigate to http://api.openweathermap.org/data/2.5/weather?q=Manchester,UK with my API key. But any of the historical calls I make are returning an Unauthorised error

Kind regards,
George

@cmfcmf
Copy link
Owner

cmfcmf commented May 6, 2016

Hi @georgeharnwell, are you on a free account? The historical weather condition api is not free, see http://openweathermap.org/price (it was free months (years?) ago but isn't anymore).

@huynhit92
Copy link

Hi @munkh-altai You should use appid not APPID

@munkh-altai
Copy link
Author

thank you all. My problem solved. ;-)
@huynhit92

@mapsgeek
Copy link

mapsgeek commented Oct 23, 2016

i'm calling it with appid={key} and it doesn't work ! this must be some kind of bug and failure in the API
i even deleted the API key and generated a new one still the same

@cmfcmf
Copy link
Owner

cmfcmf commented Oct 24, 2016

Please note that it takes a few minutes until your new api key is activated.

If the key doesn't work after a few minutes, try contacting the OpenWeatherMap team. I can't really help with that. 😕

@mcsanantonio
Copy link

I tried the answers above but to no avail. 👎

@NahidRM
Copy link

NahidRM commented Dec 30, 2016

Yup, me too. The suggestions here haven't worked

@xgqfrms-GitHub

This comment has been minimized.

@xgqfrms-GitHub

This comment has been minimized.

@xgqfrms-GitHub

This comment has been minimized.

@xgqfrms-GitHub

This comment has been minimized.

@cmfcmf

This comment has been minimized.

@302wanger
Copy link

If you are a new start,it need ten minutes or more time before the key can use

@Naveed-anwar123
Copy link

http://samples.openweathermap.org/data/2.5/weather?q=Lahore,PK&appid=542ffd081e67f4512b705f89d2a611b2
Always return London weather. What the heck any body knows?

@cmfcmf
Copy link
Owner

cmfcmf commented Aug 28, 2017

@Naveed-anwar123 you are using the samples.openweathermap.org endpoint. You should use the api.openweathermap.org endpoint instead.

@khjoony
Copy link

khjoony commented Nov 25, 2017

Caution : Notice the difference between opostrophe and grave key
API - OpenWeatherMap 날씨 Invalid api key

출처: http://booolean.tistory.com/755 [boolean]

@leosalass-zz
Copy link

Hi im haveing the next error:
Client error: GET http://api.openweathermap.org/data/2.5/api/user/city resulted in a 401 Unauthorized response: {"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}

im trying to consume two diferent services:
1- api.openweathermap.org/data/2.5/weather?lat=10.9883696&lon=-74.8051523&units=metric&appid=xxxxxxxxxxxxxxxxxxxx

2- api.openweathermap.org/data/2.5/forecast?APPID=xxxxxxxxxxxxxxxxxxx&lat=10.9883696&lon=-74.8051523&units=metric

both are working on postman and web browser, but when i use it on my project i allways get 401 error.

on my front im useing laravel with vue + axios.get
on my back im working on laravel too,

the problem persists on front and back api calls.

other importrant point, im using laravel homestead(vagrant) for develipong

@cmfcmf
Copy link
Owner

cmfcmf commented Jun 9, 2018

Hi im haveing the next error:

Could you please post the code you are using?

@leosalass-zz
Copy link

leosalass-zz commented Jun 9, 2018 via email

@kevinmholbrook
Copy link

what changes did you make?

@AnneRajan
Copy link

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

I am using valid api key still its not working please help

@YoganandamD
Copy link

If you just signed up, the automated email says that key will be activated in couple of hours. You should check back after couple of hours

@leosalass-zz
Copy link

what changes did you make?

sorry, this is too old, i dont remember

@curenosm
Copy link

curenosm commented Nov 9, 2019

Maybe it's just that you have to wait around 30 minutes to start using a new APPID, that happened to me.

@Arunprasadh93
Copy link

just wait for sometime(15 mins approx) after you signup or generate a api key, before calling the api 👍

@aero77
Copy link

aero77 commented Apr 26, 2020

You get this if trying to access a paid/premium service. Look for the free ones!

@cmfcmf cmfcmf pinned this issue May 14, 2020
@hirenbhal
Copy link

hirenbhal commented Jul 24, 2020

Remove https:// and just use api.openweathermap.org/data/2.5/weather?q=London&appid=ba24c6018ddd72041749018d0c1b1ef8&units=metric

@echu18
Copy link

echu18 commented Aug 18, 2020

Hi @munkh-altai You should use appid not APPID

this worked for me! thanks! I changed APPID to appid in Postman and the weather data replaced the error message

@aathil-Mr-ITGuy
Copy link

The major problem is, it takes couple of hours to activate the API

@jmgawecki
Copy link

hey guys. As mentioned before, I cannot get a request through my terminal as it says Invalid API key. But it does work through my browser.

curl -v http://api.openweathermap.org/data/2.5/weather?q=Berlin&APPID=MYAPIKEY - This is how I do it through my terminal. Is that wrong? Many thanks for help.

@minsoo-web
Copy link

Hey guys.
I try to every this of answers and my result was same -> 401 Invalid API Keys

My solution is

If you just sign up user or create API keys, just wait a for minutes(or more) it was solved.

@giocorvo
Copy link

giocorvo commented Jul 3, 2021

Hi @altaihero, does calling the following URL in your browser work for you (replace the X's by your api key)?

http://api.openweathermap.org/data/2.5/weather?q=Berlin&APPID=XXXXXXXXXXXXXXXXXXXXXXXX

For everyone reading this in the future: It is most likely that a new API key takes a few minutes until it works.

Hi! For me your link works, (I know the 15-30 minutes of waiting from the creation). Please help me... If it could be useful, the script is here: https://github.com/DelManari/AR-Weather

@DilinaHirantha
Copy link

you need to wait just 10-15 minutes because it will take time to activate your API key. after that you can use it as follow,

https://api.openweathermap.org/data/2.5/weather?q=London&appid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

for me it worked perfectly!

@giocorvo
Copy link

I know the 15-30 minutes of waiting from the creation

linhphan0108 added a commit to linhphan0108/NAB_Android_Technical_Challenge_Test that referenced this issue Nov 17, 2021
@Andrii-Horpynchenko
Copy link

This is a working template - https://api.openweathermap.org/data/2.5/weather?q=Kharkiv&units=metric&APPID=XXXXXXXXXXXXXXXXXXXXXXXX.
Replace XXXXXXXXXXXXXXXXXXXXXXX with your API key

@Allenkayode
Copy link

it turns out that after creating a new Api key, you just have to wait for a few mins before activiation

@ispysoftware
Copy link

hmm been waiting 2 hours, still getting the same error

@uzzal-mondal
Copy link

https://api.openweathermap.org/data/2.5/forecast/daily?q=dhaka&cnt=16&appid=d43795792c1050d9f397f55993a485d6

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

how i can solve the issues.

@shubhankar-mern
Copy link

{cod: 401, message: 'Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.'}
my api key is very old....still getting the issue ..why?

@Jatin9098
Copy link

While working with flutter I have the same issue.
While hitting the URL from browser the URL : https://api.openweathermap.org/data/2.5/weather?lat=26.5778&lon=78.494953&appid=525xxxxxxx598b

and hitting from the mobile URL will be changed to
https://api.openweathermap.org/data/2.5/weather %3F lat=26.5778&lon=78.494953&appid=525xxxxxxx598b

So after /data/2.5/weather use the query parameter while hitting the API

for Flutter it is solved below:
final queryParameters = {
'lat': '26.5778',
'lon': 78.494953',
'appid': '525xxxxxxx598b',
};
var url = Uri.https('api.openweathermap.org', '/data/2.5/weather',queryParameters);

@IoIxD
Copy link

IoIxD commented Oct 24, 2022

Unfortunately whoever downvoted that person who said it can take two hours was downvoting in vain.

OpenWeatherMap themselves say that it can take a few hours for an API key to be valid.

Why it takes so long is beyond me but I hope this helps somebody.

@rajhlinux
Copy link

Had the same issue, took about 20 mins before the API key started to work.

@SadakVali
Copy link

I too had the same issue, took about 10 mins before the API key started to work.

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

No branches or pull requests