1

I integrated Places API in my android project and it was working fine from past few months but suddenly it is giving me the following exception :-

This IP, site or mobile application is not authorized to use this API key. Request received from IP address 175.176.186.118, with empty referer

Please help me know what is the issue and how can i solve it.

I am using my Api key for getting the places response. It was working with my API key. I read on stack overflow that you need server key for this but i am unable to find any option for creating a server key.

Any help will be apreciated, Thank you.

  • Are you making a request from your android app or your computer? Is their a logcat error? If so, can you post that? – J. Jefferson Jun 30 '18 at 19:57
  • I am making the request from my android app and there is not a logcat error but google gives me the following exception- This IP, site or mobile application is not authorized to use this API key. Request received from IP address 175.176.186.118, with empty referer. – Anmol android Jul 02 '18 at 09:38

2 Answers2

1

Include a referrer in your network request.

Example: HTTP header "Referer:anmol.com"

Zun
  • 1,553
  • 3
  • 15
  • 26
  • Thank you for your reply but can you please tell me where i need to add this referrer? – Anmol android Jun 29 '18 at 09:12
  • Add it to Request Header of your Places Api call :- `Referer:yourdomain.com` – nitinkumarp Jun 29 '18 at 09:31
  • I tried adding referrer but give the following result :- API keys with referrer restrictions cannot be used with this API. – Anmol android Jun 29 '18 at 09:44
  • https://stackoverflow.com/questions/42167695/api-key-browser-api-keys-cannot-have-referer-restrictions-when-used-with-this-ap/42451277 and https://www.igorkromin.net/index.php/2016/08/09/why-browser-api-keys-cannot-have-referer-restrictions-when-used-with-this-api-error-happens/ – Zun Jun 29 '18 at 09:48
  • Sorry but i am unable to find any solution from these links – Anmol android Jun 29 '18 at 09:58
1

Check your API Restrictions for your specific project in the Google API console. You can find it by navigating to your project on the console. Select credentials in the left tab and then select the "API restrictions" tab next to "Application restrictions" near the bottom of the page. From their, click the "Select API" drop down box and select Places SDK for Android. Or you can delete all the api restrictions to have no restrictions. Also check your application restrictions to restrict it to android apps if you're not using servers to make the request. Here is a question I answered a few weeks ago on how to set that up.

J. Jefferson
  • 980
  • 8
  • 12