Unable to upload videos to youtube using java API (oAuth2). Receiving 403 Access forbidden. The request may not be properly authorized

China☆狼群 提交于 2019-11-30 18:57:51

问题


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:

来源:https://stackoverflow.com/questions/42462748/unable-to-upload-videos-to-youtube-using-java-api-oauth2-receiving-403-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!