Stay organized with collections
Save and categorize content based on your preferences.
This page describes how to use access tokens to authenticate when calling
Google Cloud APIs.
Fetching access tokens
When your code runs on Knative serving it can use the
Compute Metadata Server
to fetch access tokens. You cannot query the metadata server directly from your
local computer.
Access tokens
You use access tokens when calling Google APIs.
By default, access tokens have the cloud-platform scope, which allows access
to all Google Cloud APIs, assuming Identity and Access Management also allows access. In order to
access other Google or Google Cloud APIs, you will need to fetch an access
token with the appropriate scope.
Where SCOPES is a comma separated list of OAuth scopes
requested, for example: https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/spreadsheets.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-05 UTC."],[[["Access tokens are used to authenticate when calling Google Cloud APIs."],["Code running on Knative serving can fetch access tokens using the Compute Metadata Server."],["By default, access tokens have the `cloud-platform` scope, providing access to all Google Cloud APIs, subject to Identity and Access Management permissions."],["You can request access tokens with specific scopes using a `curl` command and including a comma-separated list of OAuth scopes."],["Only on certain services such as App Engine, Cloud Run functions, Cloud Run and Knative serving, you can use the query parameter `?scopes=` to set the scope."]]],[]]