获取授权凭据
您的应用必须有授权凭据才能使用 YouTube Live Streaming API。本文档介绍了 Google API 控制台支持的不同类型的授权凭据。另外还介绍了如何查找或创建项目的授权凭据。
创建项目并选择 API 服务
- 打开 API 控制台中的“凭据”页面。
-
您可以通过该页面创建两种不同类型的凭据。
但是,YouTube Live Streaming API 的所有方法都需要 OAuth 2.0 授权。请按照以下说明生成 OAuth 2.0 凭据。
-
OAuth 2.0:当您的应用请求非公开用户数据时,该应用必须将 OAuth 2.0 令牌随请求一起发送。要获取令牌,您的应用应先发送客户端 ID(也可能需要发送客户端密钥)。您可以为网页应用、服务账号或已安装应用生成 OAuth 2.0 凭据。
如需了解详情,请参阅 OAuth 2.0 文档。
-
API 密钥:
您可以选择在请求中包含 API 密钥。
该密钥用于标识您的项目,并提供 API 访问权限、配额和报告。
请注意,YouTube Live Streaming API 的所有方法都需要 OAuth 2.0 授权。因此,您需要按照上述说明生成 OAuth 2.0 凭据。如果需要,您还可以发送 API 密钥,但这不是必要的。
此 API 支持多种类型的 API 密钥限制。如果您需要的 API 密钥尚不存在,请在控制台中创建 API 密钥,方法是:点击创建凭据
> API 密钥。您可以先对密钥设定相关限制,然后再在生产环境中使用密钥,方法是点击限制密钥,然后选择一项限制。
为保障 API 密钥的安全,请遵循以安全的方式使用 API 密钥的最佳做法。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-03-06。
[null,null,["最后更新时间 (UTC):2024-03-06。"],[[["Authorization credentials are required for applications using the YouTube Live Streaming API."],["All 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."],["OAuth 2.0 credentials can be generated for web applications, service accounts, or installed applications through the Google API Console's Credentials page."],["While 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."],["API keys can be created and restricted within the API Console, following best practices for security."]]],["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"]]