Authorization

  • The Checks API uses OAuth 2.0 for authorization, with the scope https://www.googleapis.com/auth/checks .

  • This quickstart demonstrates authorizing requests using a service account and the gcloud CLI.

  • Setting up authorization involves installing the gcloud CLI, creating a service account, granting API access, locating your Checks account ID, and obtaining an access token.

  • You can make requests using tools like curl, including the appropriate headers for user project and authorization.

The Checks API uses OAuth 2.0 to authorize requests.

The OAuth scope is https://www.googleapis.com/auth/checks .

Authorize with OAuth 2.0

This quickstart shows you how to authorize requests with a service account using the gcloud CLI.

Set up gcloud CLI

  1. Install the gcloud CLI.
  2. Login with the gcloud CLI and set a default project:

     gcloud  
    auth  
    login 
     gcloud  
    config  
     set 
      
    project  
     PROJECT_ID 
     
    
  3. Create a service account and service account key , and set up Application Default Credentials :

     gcloud  
    iam  
    service-accounts  
    create  
     SA_NAME 
     
     gcloud  
    iam  
    service-accounts  
    keys  
    create  
    key.json  
     \ 
      
    --iam-account = 
     SA_NAME 
    @ PROJECT_ID 
    .iam.gserviceaccount.com 
      export 
      
     GOOGLE_APPLICATION_CREDENTIALS 
     = 
    key.json 
    

API callers must be users of your Checks account and have the appropriate read or write permissions.

  1. Go to the Settings page in the Checks Console and click Manage users.

  2. Invite the service account you created earlier:

      SA_NAME 
    @ PROJECT_ID 
    .iam.gserviceaccount.com 
    

Your Checks account ID is the resource ID for account resource requests.

For example, the accounts.apps.list method which lists your apps has the following format:

 https://checks.googleapis.com/v1alpha/accounts/ ACCOUNT_ID 
/apps 

You can find your account ID on the Settings page under the Account informationsection in the Checks Console.

Get an access token

 gcloud  
auth  
application-default  
print-access-token  
--scopes = 
https://www.googleapis.com/auth/checks 

Make a request

 curl  
-X  
GET  
 \ 
  
-H  
 "X-Goog-User-Project: PROJECT_ID 
" 
  
 \ 
  
-H  
 "Authorization: Bearer 
 $( 
gcloud  
auth  
application-default  
print-access-token  
--scopes = 
https://www.googleapis.com/auth/checks ) 
 " 
  
 \ 
  
 "https://checks.googleapis.com/v1alpha/accounts/ ACCOUNT_ID 
/apps" 
 
Create a Mobile Website
View Site in Mobile | Classic
Share by: