Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
授权和身份验证
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
强烈建议您在与 SAS 门户 API 集成时使用服务账号进行身份验证。如有必要,请
创建服务账号。请务必在
创建服务账号密钥时选择 JSON 作为密钥类型。创建完毕后,您的服务账号密钥将下载到浏览器的默认位置。此外,请务必向服务账号
授予“项目所有者”角色。
接下来,您需要以不记名令牌的形式提供服务账号身份验证。如果您直接调用 SAS 门户 API(例如使用 cURL 发出 HTTP 请求),您将在 Authorization 标头中以不记名令牌形式传递身份验证。如需使用您的服务账号获取不记名令牌,请按以下步骤操作:
-
安装
gcloud 命令行工具。
-
向您的服务账号进行身份验证。在以下命令中,将 ${KEY_FILE} 替换为指向服务账号密钥文件的路径:
gcloud auth activate-service-account --key-file ${KEY_FILE}
-
使用您的服务账号获取授权令牌:
gcloud auth print-access-token
该命令会返回一个访问令牌值。
-
使用该 API 时,请在 Authorization 标头中将令牌值作为 Bearer 令牌传递。请参阅以下示例:
curl -X GET -H "X-Goog-User-Project: ${CLIENT_PROJECT}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
"https://sasportal.googleapis.com/v1alpha1/customers"
将 ${CLIENT_PROJECT} 设置为您发出请求的
Google Cloud 项目的 ID,然后将 ${TOKEN} 设置为授权令牌。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2026-02-18。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2026-02-18。"],[],["The key actions are creating a service account with a JSON key, granting it the \"Project Owner\" role, and obtaining a Bearer token for API authentication. This is done by installing the `gcloud` tool, authenticating the service account using `gcloud auth activate-service-account --key-file`, and generating an access token via `gcloud auth print-access-token`. This token should then be included in the `Authorization` header when making API calls as a Bearer token.\n"]]