Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Te recomendamos que uses una cuenta de servicio para la autenticación cuando realices la integración con la API de Google Spectrum Access System (SAS) Portal.
Configurar una cuenta de servicio
Para usar una cuenta de servicio para la autenticación, completa los siguientes pasos:
Debes proporcionar la autenticación de tu cuenta de servicio como un token del portador. Si llamas a la API de SAS Portal de forma directa, por ejemplo, cuando realizas una solicitud HTTP con curl, debes pasar la autenticación como un token del portador en el encabezado Authorization.
Para obtener un token del portador con tu cuenta de servicio, sigue estos pasos:
Reemplaza ${KEY_FILE} por la ruta del archivo de claves de tu cuenta de servicio.
Usa tu cuenta de servicio para obtener un token de autorización:
gcloud auth print-access-token
El comando muestra un valor de token de acceso.
Cuando uses la API, pasa el valor del token como un token del portador en un encabezado Authorization. En la siguiente muestra de código, se muestra cómo pasar el valor del token como un token portador:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[],[],null,["# Set up authorization and authentication\n\nWe recommend that you use a service account for authentication when you\nintegrate with the Google Spectrum Access System (SAS) Portal API.\n\nSet up a service account\n------------------------\n\nTo use a service account for authentication, complete the following steps:\n\n1. [Create a service account](/iam/docs/creating-managing-service-accounts#creating_a_service_account).\n2. [Create your service account key](/iam/docs/creating-managing-service-account-keys#creating_service_account_keys)\n and select **JSON** as your key type.\n\n After you complete this step, your service account key is downloaded to your browser's default location.\n3. [Grant the **Project Owner** role](/iam/docs/granting-changing-revoking-access) to the service account.\n\nObtain a bearer token\n---------------------\n\nYou need to provide your service account authentication as a bearer token. If\nyou call the SAS Portal API directly, such as by making an HTTP\nrequest with `curl`, you pass your authentication as a bearer token in the\n`Authorization` header.\n\nTo obtain a bearer token with your service account, follow these steps:\n\n1. [Install the Google Cloud CLI](/sdk/install).\n\n2. In the gcloud CLI, authenticate to your service account:\n\n ```\n gcloud auth activate-service-account --key-file ${KEY_FILE}\n ```\n\n Replace \u003cvar translate=\"no\"\u003e${KEY_FILE}\u003c/var\u003e with the path to your service account key file.\n3. Use your service account to obtain an authorization token:\n\n ```\n gcloud auth print-access-token\n ```\n\n The command returns an access token value.\n4. When you use the API, pass the token value as a bearer token in an\n `Authorization` header. The following code sample shows how to pass the token\n value as a bearer token:\n\n ```\n curl -X GET -H \"X-Goog-User-Project: ${CLIENT_PROJECT}\" \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer ${TOKEN}\" \\\n \"https://sasportal.googleapis.com/v1alpha1/customers\"\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003e${CLIENT_PROJECT}\u003c/var\u003e: the [ID of the Google Cloud project](/resource-manager/docs/creating-managing-projects) from which you make the requests\n - \u003cvar translate=\"no\"\u003e${TOKEN}\u003c/var\u003e: the authorization token\n\nWhat's next\n-----------\n\n- To get an overview of the SAS Portal API, see [Google SAS Portal API overview](/spectrum-access-system/docs/overview-api).\n- For information about each API, see the [Customers](/spectrum-access-system/docs/customers-api) and [Device Manager](/spectrum-access-system/docs/device-manager-api) API pages.\n- For examples of how to use the API, see [API code samples](/spectrum-access-system/docs/samples).\n- For reference documentation, see [APIs and reference](/spectrum-access-system/docs/apis)."]]