Product Search Using client libraries

Installing the client libraries

Java

If you are using Maven, add this to your pom.xml file:

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-storage</artifactId>
  <version>1.37.1</version>
</dependency>

If you are using Gradle, add this to your dependencies:

compile 'com.google.cloud:google-cloud-storage:1.37.1'

If you are using SBT, add this to your dependencies:

libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "1.37.1"

If you're using VS Code, IntelliJ, or Eclipse, you can add client libraries to your project using these IDE plugins:

Besides adding client libraries, the plugins provide additional functionality, such as service account key management. Refer to the documentation for each plugin for more details.

Node.js

To install the Node.js client library:

npm install --save @google-cloud/vision

Python

The Python client library has been updated to reflect the latest changes to the Cloud Vision API Beta. These changes are not backwards-compatible with client libraries older than version 0.30.1.

To install the Python client library:

pip install --upgrade google-cloud-vision

Using the client library

To authenticate calls to Google Cloud APIs, client libraries support Application Default Credentials (ADC); the libraries look for credentials in a set of defined locations and use those credentials to authenticate requests to the API. With ADC, you can make credentials available to your application in a variety of environments, such as local development or production, without needing to modify your application code.

For a local development environment, you can set up ADC with the credentials that are associated with your Google Account:

  1. Install and initialize the gcloud CLI.

    When you initialize the gcloud CLI, be sure to specify a Google Cloud project in which you have permission to access the resources your application needs.

  2. Create your credential file:

    gcloud auth application-default login

    A sign-in screen appears. After you sign in, your credentials are stored in the local credential file used by ADC.

For more information, see Authenticate for using client libraries.