對要求進行授權
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
當您的應用程式要求公開資料時,這個要求不須取得授權,但須要附有 ID,例如 API 金鑰。
每次應用程式將要求傳送至 Google 知識圖譜 Search API 時,應用程式都必須識別自己,方法是在每個要求中加入 API 金鑰。
取得及使用 API 金鑰
要取得 API 金鑰:
- 在 API 控制台中開啟「憑證」頁面。
-
這個 API 支援兩種憑證。為專案建立適合的憑證:
-
OAuth 2.0:每當您的應用程式要求私人使用者資料時,必須隨要求傳送 OAuth 2.0 權杖。應用程式會先傳送用戶端 ID,甚至會傳送用戶端密鑰來取得權杖。您可以為網路應用程式、服務帳戶或已安裝的應用程式產生 OAuth 2.0 憑證。
注意:由於這個 API 沒有任何需要 OAuth 2.0 授權的方法,因此可能只需要取得下方說明的 API 金鑰。不過,如果您的應用程式呼叫其他需要使用者授權的 API,則您仍然需要 OAuth 2.0 憑證。
詳情請參閱 OAuth 2.0 說明文件。
-
API 金鑰:沒有提供 OAuth 2.0 權杖的要求必須傳送 API 金鑰。金鑰可用來識別專案,並提供 API 存取權、配額和報表。
API 支援數種類型的 API 金鑰限制。如果您還沒有所需的 API 金鑰,請依序點選「Create credentials」(建立憑證)
>「API key」(API 金鑰),在控制台中建立 API 金鑰。您可以先設定限制,然後再按一下「Restrict key」(限制金鑰) 並選取其中一個限制,即可對該金鑰設下限制。
為確保您 API 金鑰的安全,請遵循安全使用 API 金鑰的最佳做法。
取得 API 金鑰後,應用程式可將查詢參數 key=yourAPIKey
附加至所有要求網址。
API 金鑰可以安全地嵌入網址中,不需任何編碼。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-05-08 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2025-05-08 (世界標準時間)。"],[[["Applications need an API key to access the Google Knowledge Graph Search API, which identifies the project and provides access, quota, and reports."],["Requests for public data do not require authorization but need an identifier like an API key."],["API keys can be created and managed in the Google Cloud Console Credentials page, with options for restrictions for enhanced security."],["While OAuth 2.0 is supported, it's primarily needed for private user data and not strictly required for public data requests to this API."]]],[]]