Ruby Youtube API上传失败并显示“Missing access token”

时间:2015-10-10 17:05:36

标签: ruby youtube google-api-client

我没有找到这个问题的答案,我无法通过Ruby将视频上传到youtube。

我正在使用https://developers.google.com/youtube/v3/code_samples/ruby

中的“上传视频”

带有客户端ID,秘密等的JSON文件是从谷歌开发者控制台生成的,包含适当的数据。

C:\Projects\youtube>C:\Ruby\bin\ruby.exe C:/Projects/youtube/upload.rb --file VID_20131207_172637_752.mp4
C:/Ruby/lib/ruby/gems/2.2.0/gems/signet-0.6.0/lib/signet/oauth_2/client.rb:1009:in `generate_authenticated_request': Missing access token. (ArgumentError)
        from C:/Ruby/lib/ruby/gems/2.2.0/gems/google-api-client-0.8.6/lib/google/api_client/request.rb:241:in `to_env'
        from C:/Ruby/lib/ruby/gems/2.2.0/gems/google-api-client-0.8.6/lib/google/api_client/request.rb:161:in `send'
        from C:/Ruby/lib/ruby/gems/2.2.0/gems/google-api-client-0.8.6/lib/google/api_client.rb:648:in `block (2 levels) in execute!'
        from C:/Ruby/lib/ruby/gems/2.2.0/gems/retriable-1.4.1/lib/retriable/retry.rb:27:in `perform'
        from C:/Ruby/lib/ruby/gems/2.2.0/gems/retriable-1.4.1/lib/retriable.rb:15:in `retriable'
        from C:/Ruby/lib/ruby/gems/2.2.0/gems/google-api-client-0.8.6/lib/google/api_client.rb:645:in `block in execute!'
        from C:/Ruby/lib/ruby/gems/2.2.0/gems/retriable-1.4.1/lib/retriable/retry.rb:27:in `perform'
        from C:/Ruby/lib/ruby/gems/2.2.0/gems/retriable-1.4.1/lib/retriable.rb:15:in `retriable'
        from C:/Ruby/lib/ruby/gems/2.2.0/gems/google-api-client-0.8.6/lib/google/api_client.rb:636:in `execute!'
        from C:/Projects/youtube/upload.rb:75:in `main'
        from C:/Projects/youtube/upload.rb:93:in `<main>'

此帖Why does Google's Custom Search API say that I'm missing an access token when using the Ruby client?中的任何案例均未给出正面结果。 当我尝试使用client.authorization = nil时,我会收到谷歌的回复:

C:\Projects\youtube>C:\Ruby\bin\ruby.exe C:/Projects/youtube/upload.rb --file VID_20131207_172637_752.mp4
    {
     "error": {
      "errors": [
       {
        "domain": "global",
        "reason": "required",
        "message": "Login Required",
        "locationType": "header",
        "location": "Authorization"
       }
      ],
      "code": 401,
      "message": "Login Required"
     }
    }

平台:
Win7 64bit
ruby 2.2.1p85(2015-02-26修订版49769)[x64-mingw32]
google-api-client(0.8.6) - 我也试过0.9.pre3并获得相同的行为。

调试client.authorization和file_storage.authorization对象时包含未初始化的数据。

我做错了什么?

0 个答案:

没有答案