My API key works on my local computer but does not work on my production server. Unless I use CURL then it works in both environments. I'm just trying to get a list of movies from the DB. I'm using the URL https://api.themoviedb.org/3/discover/movie?api_key=****
I thought maybe I was using invalid headers, so I used the -I flag on CURL to get the headers and copied them over to my Axios configuration. That still didn't work. I keep getting the error message "Invalid API key: You must be granted a valid key."
Ne možete pronaći film ili TV seriju? prijavite se da biste ga napravili.
Want to rate or add this item to a list?
Not a member?
Odgovorio Travis Bell
dana 23 studeni 2018 u 2:58 PM
Hi there,
Are you able to enable some logging so you can see the full request(s) that are being made? That will probably help. When it comes to cURL issues, I've often seen a quote problem. For example, this command will not work:
While this one does:
Odgovorio zebthewizard
dana 23 studeni 2018 u 6:22 PM
CURL works perfectly. My problem is my javascript code only works in a local environment and not in production. When I enable logging in javascript I get the following JSON back on my production server.
and I get this response when I run the exact same thing in the local environment.
I double checked to make sure I'm using my API key in my JS code, which I am. Does my website have to be approved?
Odgovorio Travis Bell
dana 23 studeni 2018 u 6:26 PM
I need to see something verbose like this (from whichever client is making the request in production):
Nope, we don't do any origin validation.
Odgovorio zebthewizard
dana 23 studeni 2018 u 7:32 PM
Ok, I solved the problem. There was a misplaced space in my environment file. That is why it wasn't working on my server. I used CURL in my javascript code and that didn't work so I knew something else was wrong. Thanks for the help either way.
Odgovorio Travis Bell
dana 24 studeni 2018 u 2:12 AM
Happy to hear you sorted it out!
Odgovorio EngrZakir
dana 26 listopad 2020 u 11:56 AM
How you solve the problem? please elaborate it briefly, I am facing the same issue, invalid API key