17

We have a Google API Key that have been working for the past few months but suddenly yesterday it stop working below is the error.

2013-09-20 23:01:36.483 SampleApp[907:a0b] Google Maps SDK for iOS cannot connect or validate APIKey: Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x18828d90 {data=<CFData 0x14d04c30 [0x6174ec8]>{length = 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}} 2013-09-20 23:01:36.484 SampleApp[907:a0b] Your key may be invalid for your bundle ID: com.company.SampleApp

We were not able to find the account that own of the API key. Is there a way that we can Contact the Google Maps API team to request for help in identifying the account and help resolve the issue?

lxcid
  • 1,023
  • 1
  • 11
  • 18
  • 1
    Did you change the app bundle id in Xcode? Clearly the api key is bundled with your app bundle id to prevent api abuse. If you changed the app bundle id, then you cannot use the same api key. Check that, or just apply for a new api key using the current app bundle id. – Jing Sep 21 '13 at 20:07
  • 1
    You can mail me with your API Key at brettmorgan@google.com. I'm guessing com.company.SampleApp isn't your actual app bundle id... – Brett Sep 25 '13 at 06:34
  • 1
    Were you able to solve this? I'm experiencing the same problem. I changed bundle name and then changed it back and even if I try to recreate app ID many times, I get the same message... – mbpro Oct 21 '13 at 13:27

10 Answers10

20

I found that there is no difference for api key which surrounded with curly braces or not.

Please make sure "enable GoogleMap SDK for iOS"

You may also see reference

Community
  • 1
  • 1
sonicli
  • 401
  • 4
  • 5
  • Also the api key IS NOT be surrounded with curly braces in my case [GMSServices provideAPIKey:@"api_key"]; and works fine now. Thanks. – chuckSaldana Feb 21 '14 at 00:34
  • i forgot click on. Thanks – R00We Apr 12 '14 at 19:02
  • To elaborate on this, "Enable Google Maps SDK for iOS" has to be enabled in Google's developer console. I was encountering this error when I had enabled the SDK for Android and forgot to do it for iOS as well. – Brian Victor Apr 21 '14 at 15:38
  • This was spot on. I got caught up in checking code and making sure the API key matched and forgot to enable the service! (facepalm) –  Sep 18 '14 at 15:06
11

step by step

1.- go Google ApisConsole

2.- select Services and activate Google Maps SDK for iOS

3.- later select API Access and Create new iOS key with your bundle identifier example com.example.myProject

4.- copy Api key in your Project  [GMSServices provideAPIKey:@"kajshdklasjhdakls_LTcJWZqpRJ1BQmHxX9i0lI"]; on AppDelegate

goodluck

RAUL QUISPE
  • 800
  • 9
  • 13
5

Here are two possible fixes:

Possible Fix 1

In the line,

[GMSServices provideAPIKey:@"{AIzaSyDCPXPLUkK3UVrLr9msaS6-EsZ6UHbVgEq}"];

the api key should be surrounded with curly braces.

Possible Fix 2

In the didFinishLaunchingWithOptions method in your AppDelegate, the above line should come before you instantiate your root view controller, not after.

Matt Logan
  • 5,886
  • 5
  • 31
  • 48
4

Just my 2 cents; I enabled Google Maps for iOS in the services section of the API console after I had generated my API key which didn't work. I just deleted my key out and created a new one and hey presto (this was after a lot of testing, so it was definitely the issue, strangely).

Kieran Senior
  • 17,960
  • 26
  • 94
  • 138
1

use this code: NSLog(@"my bundle id is: %@", [[NSBundle mainBundle] bundleIdentifier]); for identify the bundle identifiers you need generated Api access in google apis.

for example: my Bundle identifier in my project x-code is projects.example.mymap, then you should copy and paste the same into apiaccess and generate this apikey.

if the problem persists, create other key and remove the last, use the new key in your app.

good luck!

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Miguel Rodríguez
  • 2,219
  • 18
  • 13
1

I had this same exact problem, ended up here searching for the answer to no avail. I was copying the API key on Google Apis and each time was seeing a "Your key may be invalid for your bundle ID: com." error.

So I decided to try typing out the API Key by hand and Voilà it worked. Definitely worth a shot, maybe somehow there are special characters being passed via copy/paste.

WiseGuy
  • 409
  • 1
  • 8
  • 19
  • Very weird, but this answer helped me. I basically copied the key from the Google APIs Console, then pasted it in my browser's URL bar, then copied it again and then pasting it in Xcode worked fine. – José Mar 02 '15 at 15:30
1

just enable google map ios sdk from your account and do not use curlie braces you will easily able to load google map.

anand madhav
  • 353
  • 4
  • 10
1

I found the solution, its occur because of bundle name differences,

  • iOS application name you used in the Google Map SDK and
  • The organization name while creating Xcode project should be matched. Just match both names, your error will get resolved.
Neha
  • 666
  • 1
  • 10
  • 17
0

pretty much all the answers on this page say the same thing.. which is the exact same thing as the instructions on the google maps sdk page..

the one thing that no one mentions is that sometimes this key takes a while to propagate on the web (ie it may not be immediately recognized by your app).. so wait up a bit.

Also one thing I found a little different is that i did not add com to the beginning of my bundle identifier.. so you can try that as well.

abbood
  • 23,101
  • 16
  • 132
  • 246
-1

I was experiencing the same problem. In "Google Developers Console" you should do:

  1. Push "Create new Key" button
  2. Select "Server key"
  3. Push "Create"
  4. Use this key in your Xcode project
Flexo
  • 87,323
  • 22
  • 191
  • 272
goodgrief
  • 378
  • 1
  • 8
  • 23