我們正在更新 Data API,以符合 YouTube 計算 Shorts 觀看次數的方式。
瞭解詳情
取得授權憑證
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您的應用程式必須具備授權憑證才能使用 YouTube Data API。
本文件說明 Google API 控制台支援的不同授權憑證類型。以及如何尋找或建立專案的授權憑證。
建立專案並選取 API 服務
- 在 API 控制台中開啟「憑證」頁面。
-
這個 API 支援兩種憑證。建立適用於專案的憑證:
-
OAuth 2.0:每當您的應用程式要求私人使用者資料時,必須一併傳送 OAuth 2.0 憑證和要求。您的應用程式會先傳送用戶端 ID,可能還會傳送用戶端密碼來取得權杖。您可以為網路應用程式、服務帳戶或已安裝的應用程式產生 OAuth 2.0 憑證。
詳情請參閱 OAuth 2.0 說明文件。
-
API 金鑰:沒有提供 OAuth 2.0 權杖的要求必須傳送 API 金鑰。金鑰可用來識別專案,並為您提供 API 存取權、配額和報表。
API 支援數種類型的 API 金鑰限制。如果您還沒有所需的 API 金鑰,請依序點選「建立憑證」
>「API 金鑰」,在控制台中建立 API 金鑰。您可以在實際工作環境中使用金鑰先加以限制,方法是點選「限制金鑰」並選取其中一個限制。
為確保您 API 金鑰的安全,請遵循安全使用 API 金鑰的最佳做法。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-03-06 (世界標準時間)。
[null,null,["上次更新時間:2024-03-06 (世界標準時間)。"],[[["\u003cp\u003eApplications using the YouTube Data API require authorization credentials for access.\u003c/p\u003e\n"],["\u003cp\u003eThe Google API Console supports two types of credentials: OAuth 2.0 tokens for private user data and API keys for general API access.\u003c/p\u003e\n"],["\u003cp\u003eOAuth 2.0 credentials can be generated for web applications, service accounts, or installed applications.\u003c/p\u003e\n"],["\u003cp\u003eAPI keys identify your project and provide API access, quota management, and usage reports, and can be restricted in scope.\u003c/p\u003e\n"],["\u003cp\u003eYou must create the credential, either the API key or OAuth 2.0, that will fit the needs of the project.\u003c/p\u003e\n"]]],["To use the YouTube Data API, your application needs authorization credentials. You can acquire these via the Google API Console. Two types are available: OAuth 2.0 tokens for private user data, obtained using a client ID and potentially a secret, and API keys for general access, project identification, quota, and reporting. Create credentials by navigating to the console's Credentials page. API keys can be further restricted. Always refer to best practices for securely using API keys.\n"],null,["Your application must have authorization credentials to be able to use the YouTube Data API.\n\nThis document describes the different types of authorization credentials that the [Google API Console](https://console.cloud.google.com/) supports. It also explains how to find or create authorization credentials for your project.\n\nCreate your project and select API services\n\n1. Open the [Credentials page](https://console.cloud.google.com/apis/credentials) in the API Console.\n2. This API supports two types of credentials. Create whichever credentials are appropriate for your project:\n - **OAuth 2.0:** Whenever your application requests private user\n data, it must send an OAuth 2.0 token along with the request. Your\n application first sends a client ID and, possibly, a client secret to\n obtain a token. You can generate OAuth 2.0 credentials for web\n applications, service accounts, or installed applications.\n\n For more information, see the [OAuth 2.0 documentation](https://developers.google.com/identity/protocols/OAuth2).\n - **API keys:**\n\n A request that does not provide an OAuth 2.0 token must send an API\n key.\n\n The key identifies your project and provides API access, quota, and\n reports.\n\n The API supports several types of restrictions on API keys. If the API key that you\n need doesn't already exist, then create an API key in the Console by\n clicking **[Create credentials](https://console.cloud.google.com/apis/credentials) \\\u003e API key** . You can restrict the key before using it\n in production by clicking **Restrict key** and selecting one of the\n **Restrictions**.\n\nTo keep your API keys secure, follow the [best practices for\nsecurely using API keys](//cloud.google.com/docs/authentication/api-keys)."]]