This IP, site or mobile application is not authorized to use this API key with IP authorized

20,776

Solution 1

I had the same issue and I found this.

On the url, it requires the server key in the end and not the api key for the app.

So Basically, you just add the server key in the end of the URL like this:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=yourlatitude,yourlongitude&radius=5000&sensor=true&key=SERVERKEY

Now, to obtain the server key, just follow these steps:

1) Go to Developer Console https://code.google.com/apis/console/

2) In the Credentials, under Public API Access , Create New key

3) Select the server key from the option.

4) Enter your IP Address on the field and if you have more ip addresses, you can just add on every single line.NOTE: Enter the IP Address only when you want to use it for your testing purpose. Else leave the IP Address section blank.

5) Once you are done, click create and your new Server Key will be generated and you can then add that server key to your URL.

Last thing is that, instead of putting the sensor=true in the middle of the URL, you can add it in the end like this:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=yourlatitude,yourlongitude&radius=5000&key=SERVERKEY&sensor=true

This will definitely solve the issue and just remember to use the server key for places api.

EDIT

I believe the web URL has changed in the past years. You can access developers console from here now - https://console.developers.google.com/apis/dashboard

  • Navigate to developers console - https://console.developers.google.com/ or use the link from details to navigate directly to API dashboard.
  • Under developer console, find Label from the left navigation panel
  • Select project
  • Choose Credentials from the left Navigation panel
  • You could create credentials type from the Top nav bar as required.

Hope this answer will help you and other viewers. Good Luck .. :)

Solution 2

You need to enable the following places api

  • Google Places API Web Service

As you are making a http request.

Share:
20,776
ip.
Author by

ip.

Updated on July 19, 2022

Comments

  • ip.
    ip. almost 2 years

    I'm using the Google Places API which requires that you give a list of IPs which are allowed to use the service. The API works great on my local machine but it give a

    This IP, site or mobile application is not authorized to use this API key

    when I use it from my production server. I've added the required IPs. Any other ideas what might be the issue or how to debug it?

  • Admin
    Admin almost 9 years
    hello mike20132013 you explained the answer very clear and step by step so in order to complete your answer i would like to add one more step which is some time programmer forget. so when you do all as in the above reply has been mentioned pretty well so then go the APIs under the APIs & auth left side pane of google map console you will see there Google Maps APIs icon press the more button and then press on Google Places API Web Service so there you will enable the api and sure you will enjoy it.
  • uiltonsantos
    uiltonsantos over 8 years
    Thanks a lot! My address search now is one hundred percent faster!
  • Rethinavel
    Rethinavel over 8 years
    I am getting error_message: "The provided API key is expired." Exception
  • mike20132013
    mike20132013 over 8 years
    Havent came across that message before but looks like ur key is expired. Try to renew the key on the dashboard and I am pretty sure you can re-generate the API key again for the app/web-app you are working for.
  • Dinesh Anuruddha
    Dinesh Anuruddha over 8 years
    nice tip you saved my day
  • Hardik Vegad
    Hardik Vegad over 5 years
    Facing the same issue, There is no API Key in Google called server key there is just a simple API key that is generated and I restricted it to Android app with adding my package name and SHA1. But still, it gives an error. Let me know How can I get Server Key ??? I am working on Mobile App for android.
  • Sushree Swagatika
    Sushree Swagatika about 4 years
    hello @mike20132013 , can you tell me where to find Public API Access . I can't find it under credentials
  • mike20132013
    mike20132013 about 4 years
    @SushreeSwagatika I believe the web URL has changed in past years. You can access developers console from here - console.developers.google.com/apis/dashboard and select project and choose credentials from the left panel and then you could create credential as required.