-1

I'm making a mobile application with Google Maps and seem to have an error with my API key. I have my API enabled and the appropriate API key, but I'm getting this error:

"error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address XX.XXX.XXX.XX, with empty referer"

I have read on this site that I need a 'Server Key' - but I can't seem to generate one. So I figure the issue is where/how I've referenced the key.

I have it in my Manifest, in the google_maps_api.xml, as well as in the activity I'm using it in.

If, and this is a tentative if as I've scoured through the Google console but if, I need a server key can someone please guide me how to do so? It seems to have been replaced/removed by Google and I'm at a loss.

Or if I'm referring to the key incorrectly either programmatically or logically could you please highlight my daft error?

Cheers in advance folks!

Eoghan Casey
  • 190
  • 3
  • 17

1 Answers1

1

double-check the package-name in the API console - and if required sign off a secondary API key for debug builds, which might sometimes have a slightly different package name; eg. when using Gradle configurations alike applicationIdSuffix. for a "mobile application", you obviously won't need a "server key"... see both of the google_maps_api.xml (in the debug and release source-sets), there should be a generated hyperlink contained, which links to the key management on the console.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • Zeitier - that's what I was thinking but on my search that's all I could find. You're a gent thanks for the guidance, hopefully that'll help me sort it! – Eoghan Casey Aug 25 '18 at 11:56
  • either I'm an idiot or this is confusing. But from my google_maps_api I have taken the package name(Which is formatted like so: 76:8A:2E:4D:0F:31:6E:0D:23:04:C2:4A:B7:64:BD:D8:81:64:XX:XX , but in my console it's saying invalid package name. What am I doing wrong? – Eoghan Casey Aug 25 '18 at 12:07
  • @EoghanCasey this is no package name but the fingerprint of a signing key (there are usually two different keys for debug & release)... there should be an URL contained, with package name and fingerprint, as URL parameters. unless not having changed the package-name after that file had been generated, that link should still have the correct parameters; else you need to adjust the package name in that link - or simply manually create those keys. – Martin Zeitler Aug 25 '18 at 12:09
  • so com.example.eoghancasey.name , OK this is in. And still throwing the same error of "request received from IP address ....". I am running this on an emulator, could that be the issue? – Eoghan Casey Aug 25 '18 at 12:12
  • @EoghanCasey you need to run an AVD image with "Google APIs"; not all of them support that... the other AVD images without "Google APIs" should not show a map, at all. – Martin Zeitler Aug 25 '18 at 12:13
  • OK so I am running it on a Pixel 2 emulator. I have my SHA-1 cert. fingerprint in as well as the package name. I can see my map & the location I have hardcoded in. Now when I try to view places around me I get this error about the IP address. – Eoghan Casey Aug 25 '18 at 12:36
  • you might have added a server key or might have added a restriction per IP ... mobile clients shouldn't have that. could post a console screenshot, but I'm not in office anymore. – Martin Zeitler Aug 25 '18 at 12:52
  • OK I'll have another go at adding a completely unrestricted/altered API key. No problem, if you could when you're back in the office throw up a screenshot. If not, no problem. Thanks for the help anyway! – Eoghan Casey Aug 26 '18 at 12:40