Unable to upload videos to youtube using java API

2020-03-05 08:24发布

I have an application which uploads videos to YouTube. Since 24 feb my application have serious issues with upload functionality. I'm using official google java client for youtube (and oauth as well).

The problem that I'm receiving 403 Forbidden using video upload API. The refresh token, auth bearer header are ok.

When I run my application first time it successfully uploads 1-2 videos and then a bit later it receives 403 from google on new requests which reuses the same connection authorization.

I even reproduced the problem in oauth playground.

How to reproduce?

  1. Enter application oauth credentials in google oauth playground
  2. Authorize youtube.upload API
  3. Exchange auth token in order to get refresh token
  4. From api test section execute POST to https://www.googleapis.com/upload/youtube/v3/videos?part=id&prettyPrint=true&uploadType=resumable - It should create empty video stub before upload

First 1-3 times the POST creates video stubs with correct youtube video id, but later it responds with:

{
  "error": {
    "code": 403, 
    "message": "Access forbidden. The request may not be properly authorized.", 
    "errors": [
      {
        "domain": "youtube.common", 
        "message": "Access forbidden. The request may not be properly authorized.", 
        "reason": "forbidden"
      }
    ]
  }
}

Here's the full response:

enter image description here

0条回答
登录 后发表回答