Lấy thông tin uỷ quyền
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Ứng dụng của bạn phải có thông tin uỷ quyền để có thể sử dụng API Phát trực tiếp trên YouTube.
Tài liệu này mô tả các loại thông tin xác thực uỷ quyền mà Google API Console hỗ trợ. Bài viết này cũng giải thích cách tìm hoặc tạo thông tin uỷ quyền cho dự án của bạn.
Tạo dự án và chọn dịch vụ API
- Mở trang Thông tin xác thực trong Bảng điều khiển API.
-
Trang này cho phép bạn tạo hai loại thông tin đăng nhập khác nhau.
Tuy nhiên, tất cả các phương thức cho API Phát trực tiếp trên YouTube đều yêu cầu bạn phải cho phép OAuth 2.0.
Hãy làm theo hướng dẫn dưới đây để tạo thông tin đăng nhập OAuth 2.0.
-
OAuth 2.0: Bất cứ khi nào ứng dụng yêu cầu dữ liệu riêng tư của người dùng, ứng dụng phải gửi mã thông báo OAuth 2.0 kèm theo yêu cầu. Trước tiên, ứng dụng sẽ gửi một mã ứng dụng khách và có thể là mật khẩu ứng dụng khách để lấy một mã thông báo. Bạn có thể tạo thông tin đăng nhập OAuth 2.0 cho các ứng dụng web, tài khoản dịch vụ hoặc ứng dụng đã cài đặt.
Để biết thêm thông tin, hãy xem tài liệu về OAuth 2.0.
-
Khoá API:
Bạn có thể thêm khoá API vào yêu cầu.
Khoá này giúp xác định dự án của bạn và cung cấp quyền truy cập API, hạn mức và báo cáo.
Xin lưu ý rằng tất cả các phương thức dành cho API Phát trực tiếp trên YouTube đều yêu cầu bạn phải cho phép OAuth 2.0.
Vì lý do đó, bạn cần làm theo hướng dẫn ở trên để tạo thông tin đăng nhập OAuth 2.0. Nếu muốn, bạn cũng có thể gửi khoá API, nhưng điều đó là không cần thiết.
API hỗ trợ một số loại hạn chế đối với khoá API. Nếu khoá API mà bạn cần chưa tồn tại, hãy tạo một khoá API trong Console bằng cách nhấp vào Tạo thông tin đăng nhập
> Khoá API. Bạn có thể hạn chế khoá trước khi sử dụng trong phiên bản phát hành công khai bằng cách nhấp vào Restrict key (Hạn chế khoá) rồi chọn một trong các Restrict (Hạn chế).
Để giữ an toàn cho khoá API, hãy làm theo các phương pháp hay nhất để sử dụng khoá API một cách an toàn.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2024-03-06 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2024-03-06 UTC."],[[["\u003cp\u003eAuthorization credentials are required for applications using the YouTube Live Streaming API.\u003c/p\u003e\n"],["\u003cp\u003eAll methods for the YouTube Live Streaming API necessitate OAuth 2.0 authorization, which requires the application to send a client ID and potentially a client secret to obtain a token.\u003c/p\u003e\n"],["\u003cp\u003eOAuth 2.0 credentials can be generated for web applications, service accounts, or installed applications through the Google API Console's Credentials page.\u003c/p\u003e\n"],["\u003cp\u003eWhile API keys are an option to identify a project, they are not necessary for the YouTube Live Streaming API, as it solely requires OAuth 2.0.\u003c/p\u003e\n"],["\u003cp\u003eAPI keys can be created and restricted within the API Console, following best practices for security.\u003c/p\u003e\n"]]],["To use the YouTube Live Streaming API, obtain authorization credentials via the Google API Console. All API methods require OAuth 2.0 authorization, which necessitates generating OAuth 2.0 credentials for web applications, service accounts, or installed applications by sending a client ID and potentially a client secret to obtain a token. While optional, you can also generate and send an API key, which identifies your project and can be created and restricted via the console.\n"],null,["Your application must have authorization credentials to be able to use the YouTube Live Streaming 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. The page allows you to create two different types of credentials. However, all of the methods for the YouTube Live Streaming API require OAuth 2.0 authorization. Follow the instructions below to generate OAuth 2.0 credentials.\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 You have the option of including an API key with a request.\n\n The key identifies your project and provides API access, quota, and\n reports.\n\n\n Note that all of the methods for the YouTube Live Streaming API require\n OAuth 2.0 authorization.\n\n\n For that reason, you need to follow the instructions above for\n generating OAuth 2.0 credentials. If you want, you can also send an\n API key, but that's not necessary.\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)."]]