Authorization
Stay organized with collections
Save and categorize content based on your preferences.
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
- Install the gcloud CLI.
Login with the gcloud CLI and set a default project:
gcloud auth login
gcloud config set project PROJECT_ID
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
Grant API access to your Checks account
API callers must be users of your Checks account and have the appropriate read
or write permissions.
Go to the Settings page
in the Checks Console and click Manage users.
Invite the service account you created earlier:
SA_NAME@PROJECT_ID.iam.gserviceaccount.com
Locate your account ID
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 information section 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"
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-11-08 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-08 UTC."],[[["\u003cp\u003eThe Checks API utilizes OAuth 2.0 for authorization, requiring the \u003ccode\u003ehttps://www.googleapis.com/auth/checks\u003c/code\u003e scope.\u003c/p\u003e\n"],["\u003cp\u003eTo use the API, you need to set up the gcloud CLI, create a service account, and grant it access to your Checks account.\u003c/p\u003e\n"],["\u003cp\u003eYour Checks account ID is necessary for making API requests and can be found in the Checks Console settings.\u003c/p\u003e\n"],["\u003cp\u003eYou can obtain an access token using the gcloud CLI and then use it to make requests to the Checks API.\u003c/p\u003e\n"]]],[],null,["# Authorization\n\nThe Checks API uses [OAuth 2.0](https://developers.google.com/identity/protocols/oauth2) to authorize requests.\n\nThe OAuth scope is `https://www.googleapis.com/auth/checks`.\n\nAuthorize with OAuth 2.0\n------------------------\n\nThis quickstart shows you how to authorize requests with a service account using\nthe gcloud CLI.\n\n### Set up gcloud CLI\n\n1. [Install](https://cloud.google.com/sdk/docs/install) the gcloud CLI.\n2. Login with the gcloud CLI and set a default project:\n\n gcloud auth login\n gcloud config set project \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\n3. Create a [service account](https://cloud.google.com/iam/docs/service-accounts-create) and\n [service account key](https://cloud.google.com/iam/docs/keys-create-delete), and set up\n [Application Default Credentials](https://cloud.google.com/docs/authentication/application-default-credentials):\n\n gcloud iam service-accounts create \u003cvar translate=\"no\"\u003eSA_NAME\u003c/var\u003e\n gcloud iam service-accounts keys create key.json \\\n --iam-account=\u003cvar translate=\"no\"\u003eSA_NAME\u003c/var\u003e@\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e.iam.gserviceaccount.com\n export GOOGLE_APPLICATION_CREDENTIALS=key.json\n\n### Grant API access to your Checks account\n\nAPI callers must be users of your Checks account and have the appropriate read\nor write permissions.\n\n1. Go to the [Settings](https://checks.google.com/console/settings) page\n in the Checks Console and click **Manage users**.\n\n2. Invite the service account you created earlier:\n\n \u003cvar translate=\"no\"\u003eSA_NAME\u003c/var\u003e@\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e.iam.gserviceaccount.com\n\n### Locate your account ID\n\nYour Checks account ID is the [resource ID](https://google.aip.dev/122#resource-id-segments) for account resource\nrequests.\n\nFor example, the [`accounts.apps.list`](/checks/reference/rest/v1alpha/accounts.appps/list) method which lists\nyour apps has the following format: \n\n https://checks.googleapis.com/v1alpha/accounts/\u003cvar translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e/apps\n\nYou can find your account ID on the\n[Settings](https://checks.google.com/console/settings) page under the\n**Account information** section in the Checks Console.\n\n### Get an access token\n\n gcloud auth application-default print-access-token --scopes=https://www.googleapis.com/auth/checks\n\n### Make a request\n\n curl -X GET \\\n -H \"X-Goog-User-Project: \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\" \\\n -H \"Authorization: Bearer $(gcloud auth application-default print-access-token --scopes=https://www.googleapis.com/auth/checks)\" \\\n \"https://checks.googleapis.com/v1alpha/accounts/\u003cvar translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e/apps\""]]