Can Google Cloud API key restricitons be applied to an existing app?

108 Views Asked by At

At first I was interested to learn if I could rotate the main api key for my iOS firebase app. That is the value API_KEY in the GoogleService-Info.plist file downloaded from the firebase console.

After some digging around I found that it is possible to create a new key in:

Cloud console -> APIs & Services -> Credentials

I created a new key swapped the value in my plist, tested my app and successfully was able to use the new key, great!

Now the next part, I noticed that in the key settings there is an option to "Set an application restriction" this can be set to "iOS apps" and enter the app bundle id.

When I tried doing this I was getting an error trying to authenticate in the app.

reason: API_KEY_IOS_APP_BLOCKED

I found a similar question, which was resolved: How to restrict Firebase API keys in the Google Cloud console

But if this answer is correct it suggests that the key must be created before the project is created. I understand from this that when the config is created it checks for a key containing the app bundle id, otherwise create a new one.

My app is live with users on it so starting again is not an option here so is it possible to use this kind of application restriction on my existing app and project?

0

There are 0 best solutions below