获取授权凭据
您的应用必须具有授权凭据才能使用 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 密钥的最佳做法。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-03-06。
[null,null,["最后更新时间 (UTC):2024-03-06。"],[[["Applications using the YouTube Data API require authorization credentials for access."],["The Google API Console supports two types of credentials: OAuth 2.0 tokens for private user data and API keys for general API access."],["OAuth 2.0 credentials can be generated for web applications, service accounts, or installed applications."],["API keys identify your project and provide API access, quota management, and usage reports, and can be restricted in scope."],["You must create the credential, either the API key or OAuth 2.0, that will fit the needs of the project."]]],[]]