Aerial View API supports the use of OAuth 2.0 for authentication. Google supports common OAuth 2.0 scenarios such as those for a web server.
This document describes how to pass an OAuth token to the Aerial View API call in your development environment. For instructions on using OAuth in a production environment, see Authentication at Google.
Before you begin
Before you start using the Aerial View API, you need a project with a billing account and the Aerial View API enabled. We recommend creating multiple Project Owners and Billing Administrators, so that you'll always have someone with these roles available to your team. To learn more, see Set up in Cloud Console.
There are many ways to create and manage access tokens with OAuth based on your deployment environment.
For example, the Google OAuth 2.0 system supports server-to-server interactions, such as those between your application and a Google service. For this scenario you need a service account, which is an account that belongs to your application instead of to an individual end user. Your application calls Google APIs on behalf of the service account, so users aren't directly involved. For more information on authentication methods, see Authentication at Google.
Alternatively, you might use the Aerial View API as part of an Android or iOS mobile app. For general information on using OAuth with the Aerial View API, including information on managing access tokens for different deployment environments, see Using OAuth 2.0 to Access Google APIs.
About OAuth scopes
To use OAuth with the Aerial View API, the OAuth token must be assigned the scope:
Example: Try REST API calls in your local development environment
If you want to try the Aerial View API using an OAuth token, but do not have an environment setup to generate tokens, you can use the procedure in this section to make the call.
This example describes how to use the OAuth token provided by Application Default Credentials (ADC) to make the call. For information about using ADC to call Google APIs using client libraries, see Authenticate using client libraries.
Before you can make a REST request using ADC, use the Google Cloud CLI to provide credentials to ADC:
- If you haven't already, create a project and enable billing by following the steps in the Set Up in the Google Cloud Console.
- Install and initialize the gcloud CLI.
Run the following
gcloudcommand on your local machine to create your credential file:
gcloud auth application-default login
- A login screen is displayed. After you log in, your credentials are stored in the local credential file used by ADC.
For more information, see Local development environment section of the Provide credentials for Application Default Credentials documentation.
Make a REST request
In this example, you pass two request headers:
Pass the OAuth token in the
Authorizationheader by using the following command to generate the token:
The returned token has a scope of
- Pass the ID or name of your Google Cloud project that has billing enabled in the
X-Goog-User-Projectheader. To learn more, see Set up in Cloud Console.
The following example makes a call to the Aerial View API using an OAuth token:
curl -X GET \ -H 'X-Goog-User-Project: PROJECT_NUMBER_OR_ID' \ -H "Authorization: Bearer $TOKEN" \ "https://aerialview.googleapis.com/v1/videos:lookupVideo?&address=1600%20Amphitheatre%20Pkwy%2C%20Mountain%20View%2C%20CA%2094043"
If your request returns an error message about end-user credentials not being supported by this API, see User credentials not working.