This post outlines the steps to obtain credential keys for GCP in order to programmatically access their API services.
You need to have a Google Cloud account with billing enabled. You can follow the instructions here in case you don’t have this set up already.
Step – 1
Open Cloud Vision console.
Step – 2
If you haven’t created a project yet or want to create a new project for the purpose of this chapter, follow the steps below. Otherwise, move to Step 3.
In the Cloud Console, in project selector page, click on Create Project button (top right).
Enter the project details such as project name, organization, and location, and then create the project.
Step – 3
Open the APIs & Services dashboard in the Google Cloud console.
Click on the ENABLE APIS AND SERVICES button at the top.
Next, search for Cloud Vision API by entering “vision” in the search bar.
Select the Cloud Vision API result from the search.
Now click on the ENABLE button to enable the Cloud Vision API for your current project.
Enabling the API is a crucial step. If you don’t enable the API you won’t be able to use it.
Step – 4
After the last step, you should automatically be on the Cloud Vision API's Overview page. If not, then use this
link to the open Cloud Vision API’s Overview page. Now click on Credentials on the left side of the page.
Next, to add credentials to your project –
- First, select which API we will be using. In our case, it’s the Cloud Vision API.
- Second, since we will not be using the API with App Engine or Compute Engine, select No, I’m not using them.
- Then click on the What credentials do I need? button.
Next, we need to create a service account –
- Add the account name and set the role as Owner (Project → Owner).
-
Note: The Role field authorizes your service account to access resources. You can view and change this field later by using the Cloud Console. If you are developing a production app, specify more granular permissions than Project → Owner. For more information, see granting roles to service accounts.
- Then click the Continue button.
Once you click Continue, you should get a prompt to download a json file with all the credentials.
Now copy the contents of the json
file we downloaded in the previous step into the client_id.json
in the chapter (Chapter 16, Practitioner Bundle, OCR Book) directory. Now we are all set to OCR images using Google Vision API!