I googled it
To obtain an API key for Google services, follow these steps:
Access the Google Cloud Console:
Navigate to the Google Cloud Console in your web browser. You will need to sign in with a Google account.
Select or Create a Project:
If you already have a project, select it from the project list. Otherwise, create a new project and give it a name.
Navigate to Credentials:
In the Google Cloud Console, go to the "APIs & Services" section and then select "Credentials."
Create API Key:
On the Credentials page, click "Create credentials" and then choose "API key."
Copy the API Key:
Your new API key will be displayed in a dialog box. Copy this key, as it will be used to authenticate your application's requests to Google APIs.
Restrict the API Key (Recommended):
For security purposes, it is highly recommended to restrict your API key. You can do this by editing the key and specifying where and for which APIs it can be used. For example, you can restrict it to specific websites (HTTP referrers) or IP addresses