I'm using MakerSuite with Gemini and I deleted an API Key. I went to create a new one, but I'm getting an error saying the caller does not have permission. What does that mean and how can I get a key?
"The caller does not have permission" when creating API key
2.5k views Asked by Prisoner AtThere are 3 answers
Google has apparently limited it to one key per project, probably as part of a plan to make sure people don't use multiple keys to get around the rate limit.
There appears to be a bug, however, where you can delete an API Key... but you won't be able to create a new one because Google thinks the key still exists.
In a way - it does.
The API Keys are actually associated with a Google Cloud project that gets created when you create a new key (the "Create API key in new project" button in the question). The MakerSuite console, however, hides this information behind the scenes to make it easier for developers to get started. When you delete a key, Google Cloud makes it so it can't be used - but also allows you to "undelete" it within 30 days in case there was a mistake. We'll use this fact to get your key back so you can use it.
To get the key back, we'll go into the Google Cloud Console credentials page and restore the deleted key.
Go directly to the credentials page in Google Cloud Console at https://console.cloud.google.com/apis/credentials
- Make sure the account is the same as the one you're using for MakerSuite. You should be able to see the account in the upper right hand corner.
- If you have more than one project, make sure you're using the right one. The default keys are created in a project named "Generative Language Client", but you may have done it in a different project.
Select the "Restore Deleted Credentials" link.
For the key with the name "Generative Language API Key", select the "RESTORE" link.
On the pop-up, click the "RESTORE" button again. Then click the back arrow to leave the "Deleted credentials" page.
On the Credentials page, you'll see that the credential has been restored.
And if you go back to the MakerSuite Google AI Studio, you'll see that the key now shows up there as well.
In some cases you actually want to keep the key deleted and need a new one. For example, you may have accidentally included the API Key in code that you posted on GitHub, and now need to invalidate it so nobody else can use it. But that means you'll need a new one.
You won't be able to use the Google AI Studio page to do this, but you will be able to do it through the Google Cloud Console page.
As above, you would go directly to the credentials page in Google Cloud Console at https://console.cloud.google.com/apis/credentials
This time, however, you would select the "Create Credentials" link along the top and in the drop-down menu select "API key"
The system will create the key and pop up a message saying it has done so, and let you copy the key at this time. More importantly, however, you'll see a warning that the key is unrestricted. This is a bad idea from a security perspective, so you should click on "Edit API key" to restrict how the key will be used.
We want to restrict this so it can only use the Generative Language API, so we'll select the radio button to "Restrict key" and then make sure we locate and check the box next to "Generative Language API" and click on OK.
We can also do other things from this page, such as change the name so it will be more obvious what it is used for, but that isn't necessary. Instead, we'll just save these settings.
While the key will show up in the Google Cloud Console, it won't appear in the MakerSuite Google AI Studio key page. Instead, if you want to manage this key in the future, you'll need to do it from this page.
i go back to the MakerSuite Google AI Studio,but i didn't see any API key!!!