kylejginavan / youtube_it

An object-oriented Ruby wrapper for the YouTube GData API
http://groups.google.com/group/ruby-youtube-library
595 stars 223 forks source link

Token invalid error - any help? #253

Open funkenstrahlen opened 9 years ago

funkenstrahlen commented 9 years ago

Hey, I try to use this code in my project:

https://github.com/funkenstrahlen/podcast-to-youtube/blob/master/main.rb#L12-L41

However I get an invalid token when trying to upload a video. This is what happens:

connecting to youtube account
open this url in a browser:
https://accounts.google.com/o/oauth2/auth?client_id=911313852664-tir6o945mdn2bouorhpalkecrg23dng9.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://gdata.youtube.com&response_type=code&approval_prompt=force&access_type=offline
enter the access token:
4/vzYdnu9Fiy1Y5dNTZ2QnTp####censored##########
I, [2015-09-28T18:30:13.278137 #20901]  INFO -- : post https://accounts.google.com/o/oauth2/token
D, [2015-09-28T18:30:13.278344 #20901] DEBUG -- request: User-Agent: "Faraday v0.9.1"
Content-Type: "application/x-www-form-urlencoded"
I, [2015-09-28T18:30:13.826192 #20901]  INFO -- Status: 200
D, [2015-09-28T18:30:13.826445 #20901] DEBUG -- response: content-type: "application/json; charset=utf-8"
x-content-type-options: "nosniff"
cache-control: "no-cache, no-store, max-age=0, must-revalidate"
pragma: "no-cache"
expires: "Fri, 01 Jan 1990 00:00:00 GMT"
date: "Mon, 28 Sep 2015 16:30:13 GMT"
content-disposition: "attachment; filename=\"json.txt\"; filename*=UTF-8''json.txt"
p3p: "CP=\"This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info.\""
x-frame-options: "SAMEORIGIN"
x-xss-protection: "1; mode=block"
server: "GSE"
set-cookie: "NID=71=IRKSKi8FcOfMXhudTB_a5200TI_mFeFE_HePbPt3AKAWrEunwnqjRWZ7KCoZ5h2aCa6Xju2-XjuB_av5nfNIOKAd1pGT69C9ABFrR6DkqUDEROpcJszqh57DHYyhdT01;Domain=.google.com;Path=/;Expires=Tue, 29-Mar-2016 16:30:13 GMT;HttpOnly"
alternate-protocol: "443:quic,p=1"
alt-svc: "quic=\":443\"; p=\"1\"; ma=604800"
accept-ranges: "none"
vary: "Accept-Encoding"
connection: "close"

[...]

uploading videofile to Youtube
/var/lib/gems/1.9.1/gems/oauth2-1.0.0/lib/oauth2/client.rb:113:in `request': <HTML> (OAuth2::Error)
<HEAD>
<TITLE>Token invalid</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Token invalid</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
        from /var/lib/gems/1.9.1/gems/oauth2-1.0.0/lib/oauth2/access_token.rb:107:in `request'
        from /var/lib/gems/1.9.1/gems/oauth2-1.0.0/lib/oauth2/access_token.rb:114:in `get'
        from /var/lib/gems/1.9.1/gems/youtube_it-2.4.2/lib/youtube_it/client.rb:523:in `current_user'
        from /var/lib/gems/1.9.1/gems/youtube_it-2.4.2/lib/youtube_it/client.rb:538:in `client'
        from /var/lib/gems/1.9.1/gems/youtube_it-2.4.2/lib/youtube_it/client.rb:117:in `video_upload'
        from main.rb:70:in `block in <main>'
        from main.rb:43:in `each'
        from main.rb:43:in `<main>'

I really do not know how to debug this further. Any help?

funkenstrahlen commented 9 years ago

This might happen because of the deprecated Youtube API V2. This gem does not support the current API V3. I now switched to the yt gem to upload videos to Youtube.