如何配置自定义YouTube Internal API密钥以解决403错误
问题:自定义API密钥调用YouTubei API返回403禁止访问错误
背景
我在应用中通过YouTubei API播放YouTube视频,近期视频加载变慢,发现默认API密钥AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8已超出使用限额。替换为自己创建的API密钥后,收到403 Forbidden错误,提示YouTube Internal API (InnerTube) has not been used in project。
已尝试操作
- 启用YouTube Data API V3并创建凭据
- 尝试访问YouTubei API的控制台启用页面,但页面加载失败
请求信息
请求URL:https://www.youtube.com/youtubei/v1/player?key=[我的API密钥]
错误响应
{ "error": { "code": 403, "message": "YouTube Internal API (InnerTube) has not been used in project 910740975396 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtubei.googleapis.com/overview?project=910740975396 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", "errors": [ { "message": "YouTube Internal API (InnerTube) has not been used in project 910740975396 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtubei.googleapis.com/overview?project=910740975396 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", "domain": "usageLimits", "reason": "accessNotConfigured", "extendedHelp": "https://console.developers.google.com" } ], "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.rpc.Help", "links": [ { "description": "Google developers console API activation", "url": "https://console.developers.google.com/apis/api/youtubei.googleapis.com/overview?project=[project id]" } ] }, { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "SERVICE_DISABLED", "domain": "googleapis.com", "metadata": { "service": "youtubei.googleapis.com", "consumer": "projects/[project id]" } } ] } }
解决方案
启用YouTubei API服务
YouTube Data API V3和YouTubei API是独立服务,启用前者不代表后者自动开启。需在Google Cloud控制台的API库中搜索YouTube Internal API (InnerTube)或youtubei.googleapis.com,找到后启用该服务。排查API密钥配置
- 检查API密钥是否关联到正确的项目,且该项目已启用YouTubei API。
- 确认API密钥的IP/HTTP referrer限制是否允许当前请求来源,若有限制需调整规则或暂时移除限制测试。
解决控制台页面加载问题
若直接访问指定启用页面失败,可通过控制台主路径进入:选择目标项目 → 进入「API和服务」→ 打开「API库」→ 搜索目标API进行启用。若仍加载失败,换网络环境或稍后重试。等待配置同步
API启用后,系统需要几分钟时间同步配置,不要立即重试,等待10-15分钟后再测试请求。检查API配额
确认新密钥对应的YouTubei API配额足够,避免再次触发限额导致加载缓慢。
内容的提问来源于stack exchange,提问作者GEO
相关产品推荐
相关产品推荐

