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."
Can't find a movie or TV show? Login to create it.
Want to rate or add this item to a list?
Not a member?
Reply by Travis Bell
on November 23, 2018 at 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:
Reply by zebthewizard
on November 23, 2018 at 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?
Reply by Travis Bell
on November 23, 2018 at 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.
Reply by zebthewizard
on November 23, 2018 at 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.
Reply by Travis Bell
on November 24, 2018 at 2:12 AM
Happy to hear you sorted it out!
Reply by EngrZakir
on October 26, 2020 at 11:56 AM
How you solve the problem? please elaborate it briefly, I am facing the same issue, invalid API key