How to Build a Monitoring Application With the Google Cloud Vision API

It will take a few moments to create the project. Once the project is created successfully, you will be lead to the Project dashboard.

2. Enable Google Cloud Vision API for Your Project

The next step is to enable the Cloud Vision API for your project. Click on the hamburger menu on top and then on API Manager as shown below:

google cloud vision api manager

The Cloud Vision API is not enabled for your project. Google provides several APIs and we need to find the Cloud Vision API. Enter the word “Vision” in the filter field as shown below and Cloud Vision API should come up as shown below:

google cloud vision api find api

This will bring up the details on the Cloud Vision API along with a button labelled Enable. Click on that button to enable the Cloud Vision API. The label will switch to Enabling… and in a few moments, the API will be enabled as shown below:

google cloud vision api enable api

The message clearly indicates that you cannot use the API till you create the credentials. The credentials will be used in your application to identify itself to the Cloud Vision API, which will then authorize you to access the service.  

3. Getting Credentials

Visit the API Manager link again from the hamburger menu and click on Credentials. This will bring up a choice of what kind of Authentication mechanism that we want. For maximum flexibility, we will go with the Service Account Key, which will allow us access to the Vision API from applications running and is recommended for production use. Plus with the Application Credentials feature, authentication and authorization has been greatly simplified for the Google APIs.

Once you select the Service Account Key, you will see a screen as shown below:

Click on the Select option for Service Account and choose New Service Account. This will bring up the form as shown below:

google cloud vision api credentials

Enter a name for the account, leave the Key Type as JSON and click on Create. This will create the JSON file containing your security keys and you will see a message that indicates that the file has been generated. It will also download the JSON file to your system. Keep it secure and we will be using it next to set the credentials for the application.

4. Use the Application Default Credentials

This feature makes it dead simple to integrate authentication to Google APIs in your applications. Check out the documentation.

All we need to do is set an environment variable named GOOGLE_APPLICATION_CREDENTIALS and its value will be the JSON key file that we just downloaded in the previous step.

Be sure to read the next Machine Learning article: An Analysis of Brexit With the MonkeyLearn Machine Learning API