You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用captions.update时遭遇403 Forbidden错误求助

排查YouTube Captions API更新接口403权限错误

环境

  • 语言:Python 3.10
  • 库:google-api-python-client v2.x
  • OAuth权限范围:
SCOPES = [
    'https://www.googleapis.com/auth/youtube.upload',
    'https://www.googleapis.com/auth/youtube',
    'https://www.googleapis.com/auth/youtube.force-ssl',
    'https://www.googleapis.com/auth/spreadsheets',
    'https://www.googleapis.com/auth/drive'
]

操作步骤

  1. 从token.pickle加载已保存的凭证,过期则自动刷新
  2. 构建YouTube服务实例:
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build

creds = Credentials.from_authorized_user_file('token.pickle', SCOPES)
youtube = build('youtube', 'v3', credentials=creds)
  1. 调用captions.update接口:
request = youtube.captions().update(
    part='snippet',
    body={
        'id': '<CAPTION_TRACK_ID>',
        'snippet': {
            'language': 'en',
            'name': 'English captions',
            'isDraft': False
        }
    },
    media_body=MediaFileUpload('captions_en.vtt', mimetype='text/vtt')
)
response = request.execute()
print(response)

错误信息

{
  "error": {
    "code": 403,
    "message": "The permissions associated with the request are not sufficient to update the caption track. The request might not be properly authorized.",
    "errors": [
      {
        "domain": "youtube.caption",
        "reason": "forbidden",
        "message": "The permissions associated with the request are not sufficient to update the caption track. The request might not be properly authorized.",
        "location": "id",
        "locationType": "parameter"
      }
    ]
  }
}

已完成的排查

  • 通过tokeninfo端点验证访问令牌包含youtube.force-ssl权限
  • 删除token.pickle并重新执行OAuth流程获取新令牌
  • 调用youtube.videos().list(mine=True)确认视频channelId与当前频道匹配
  • 尝试改用captions.insert上传全新字幕而非更新现有轨道
  • 确认目标视频无自动生成字幕轨道(此类轨道无法更新)

请求帮助

已完成上述排查仍收到403错误,是否存在其他需要配置的权限或参数(尤其针对非品牌频道)?

内容的提问来源于stack exchange,提问作者Kenji Ishikawa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 16:45:14