0

I've not found answer for this question and I am not able to upload video to youtube by Ruby.

I am using "Upload a video" from https://developers.google.com/youtube/v3/code_samples/ruby

JSON file with client-ID, secret etc. was generated from google developers console and contains proper data.

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>'

Any case from this post Why does Google's Custom Search API say that I'm missing an access token when using the Ruby client? do not give positive results. When i try to use client.authorization = nil I get following reply from google:

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"
     }
    }

Platform:
Win7 64bit
ruby 2.2.1p85 (2015-02-26 revision 49769) [x64-mingw32]
google-api-client (0.8.6) - also I tried 0.9.pre3 and get the same behavior.

When debugging client.authorization and file_storage.authorization objects contain uninitialized data.

What am I doing wrong?

Community
  • 1
  • 1
Igor
  • 1,589
  • 15
  • 15
  • Please add a bit of code snippet of the file `upload.rb` where you think the error is getting generated. – harshs08 Oct 10 '15 at 19:41
  • Errors are always generated when calling`videos_insert_response = client.execute!( :api_method => youtube.videos.insert, :body_object => body, :media => Google::APIClient::UploadIO.new(opts[:file], 'video/*'), :parameters => { :uploadType => 'resumable', :part => body.keys.join(',') } )` – Igor Oct 11 '15 at 07:33
  • Given code on Ruby is for YouTube Data API (v2) YouTube Data API (v3) is current version and old Ruby code is not work I guess. – Igor Nov 05 '15 at 17:14

0 Answers0