apigoogle-searchgoogle-custom-searchgoogle-search-api

Google custom search: can't get api key


I want to programmatically search the web using Google, and after hours of Google searching I have found this answer, but it was written in 2016 and many things have changed since then.

Following the tutorial, I created a stub custom search engine that indexes the entire internet, you can view my search engine if you want, not sure if you have permission to do so though.

Then I clicked Get started button on the right of Custom Search JSON API, got redirected here:

https://developers.google.com/custom-search/v1/introduction

I clicked that big Get a Key button and this happened:

enter image description here

Couldn't initialize

Service 'customsearch' not found or permission denied.

I searched that message and found exactly nothing relevant.

Then I went to console.cloud.google.com and enabled Custom Search API for the stub project I had to create in order to access youtube-data-api-v3:

https://console.cloud.google.com/apis/api/customsearch.googleapis.com/metrics?project=project-athena-348708

enter image description here

I noticed that its name is customsearch.googleapis.com and not customsearch.

Then I clicked CREATE CRENDENTIALS button and was forced to try to create a stupid nonsensical useless service account just to get an API key, because there is no other way to get an API key...

enter image description here

And it took forever and failed every single time...

What can I try, at this point, to get a customsearch API key?


Solution

  • Turns out the solution is extremely simple, in fact it is so simple it is stupid.

    The solution? Don't click that big and obvious CREATE CRENDENTIALS button, because that is clearly what Google wants us users to click, and chances are extremely high that is not what you wanted.

    Then how to get an API key to the service?

    Well any API key associated with the project is a valid API key for any service enabled in the project, I only figured it out because API key 1 text in "Credentials" box.

    But it recommended to use different API keys for different API services because each free API key has a 10,000 daily use quota.

    Then how to create an API key?

    Well, in the left pane, click Credentials, then click + CREATE CRENDENTIALS, then choose API key, done.