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

uninitialized constant OAuth2 #185

Closed srussking closed 11 years ago

srussking commented 11 years ago

I have stumbled on a problem that is perplexing me. I got the youtube_it gem working several months ago, but got pulled off onto another project before this one was in production. However now that I have come back to this code it is throwing an error uninitialized constant OAuth2 on refresh_access_token (or really anything in Oauth2Client that utilizes that object)

The code was working several months ago and was connecting, pulling videos and uploading videos just fine. However since then we have upgraded to Rails 4, and added a number of new gems.

The YoutubeIt session is getting created via YouTubeIt::OAuth2Client.new(client_access_token: youtube_client_access_token, client_refresh_token: youtube_refresh_token ,client_id: youtube_client_id, client_secret: youtube_client_secret, dev_key: youtube_dev_key)

However after that a call to yt_session.refresh_access_token! results in the unintialized constant error shown here with the relevent(?) bits of the trace. youtube_it (2.1.4) lib/youtube_it/client.rb:426:in access_token' youtube_it (2.1.4) lib/youtube_it/client.rb:430:inrefresh_access_token!' /Users/russ/Rails/mbcms/app/models/youtube_item.rb:80:in `refresh' ...

I have tried:

Requiring oauth2 adds a different error: A refresh_token is not available oauth2 (0.5.2) lib/oauth2/access_token.rb:80:in refresh!' youtube_it (2.1.4) lib/youtube_it/client.rb:430:inrefresh_access_token!' /Users/russ/Rails/mbcms/app/models/youtube_item.rb:81:in `refresh' ...

Anyone seen this error before, or have some ideas on things to try?

Thanks, Russ

srussking commented 11 years ago

New wrinkle. Discovered that adding a require 'oauth2' somewhere in the pipeline (config.rb, model, controller) allows the connection to work once. However the refresh_access_token! still blows up with the "A refresh_token is not available" message above.

srussking commented 11 years ago

Seems to have been a problem with youtube. Since while I was busy documenting where it was failing, it all started working again. Can't say I'm 100% happy with that resolution, but since it is all working again, I'm gonna go ahead and close this one.