Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
授權與驗證
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
整合 SAS Portal API 時,我們強烈建議您使用服務帳戶進行驗證。如有需要,請
建立服務帳戶。請務必在
建立服務帳戶金鑰時,選取 JSON 做為金鑰類型。完成之後,服務帳戶金鑰會下載到瀏覽器的預設位置。此外,請務必
將「專案擁有者」角色授予服務帳戶。
接著,您需要以不記名權杖的形式提供服務帳戶驗證。如果直接呼叫 SAS Portal API (例如提出具有 cURL 的 HTTP 要求),則會在 Authorization 標頭中以不記名憑證的形式傳送驗證。如要使用服務帳戶取得不記名憑證,請按照下列步驟操作:
-
安裝
gcloud 指令列工具。
-
驗證服務帳戶。在下列指令中,將 ${KEY_FILE} 替換為服務帳戶金鑰檔案的路徑:
gcloud auth activate-service-account --key-file ${KEY_FILE}
-
使用服務帳戶取得授權權杖:
gcloud auth print-access-token
此指令會傳回存取憑證值。
-
使用 API 時,請將憑證值做為 Bearer 憑證傳送至 Authorization 標頭中。請參閱以下範例:
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} 設為授權權杖。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間: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"]],["上次更新時間: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"]]