Now You Can Have Better Youtube Integration with Ruby on Rails
I recently wanted to upload, edit, update and delete a video directly on youtube from my rails application. This can be achieved by YouTube Data API that allows application to perform functions normally executed on youtube.
Step 1 : Demystifying Authentication with Google AuthSub
Google provides an authentication service to those web applications that need to access services protected by a user’s Google account. I chose Google’s ‘AuthSub’ scheme for this. This also provides a high level of security to web application.
The AuthSub interface provides several methods for acquiring and managing authorization tokens. Once a web application has received a token, it can request access to a Google service.
To obtain an authentication token, submit an HTTP POST request to the following URL:
https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Fwww.example.com%2Fupload.html&scope=http%3A%2F%2Fgdata.youtube.com&session=0&secure=0
Setting session parameter to 1 indicates that the single-use token can be exchanged for a session token.
AuthSubSessionToken is a method that allows the web application to exchange a single-use token for a session token. I used a gem ‘gdata’ to convert the token into a session token.
client = GData::Client::DocList.new client.authsub_token = params[:token] session[:token] = client.auth_handler.upgrade()
Session token allows the application to make unlimited calls to the Google service. When using session tokens, your application should store the session token for each user rather than requesting a new one each time it needs to access a Google service. For other token management options, see Working With AuthSub.
Step 2 : Getting the Youtube Developer Key
A developer key is required that identifies the YouTube developer that is submitting an API request. A client ID identifies your application for logging and debugging purposes. Please visit here to obtain a developer key and client ID.
Step 3 : Improving the Youtube Model Plugin
“youtube-model” is a plugin that provides youtube video uploading functionality. That was a good start.
I forked the plugin and updated it with few methods to get the rest of the functionality done. Each method is explained here.
1. uploaded_by_user
A method uploaded_by was provided in the plugin to retrieve all the videos of the user but it receives username as a parameter. So I added a method uploaded_by_user that receives the session token and solves our purpose.
YouTube.uploaded_by_user(session[:token])
2. update_video
The video can be updated by using this method passing video id, session token and params hash as parameters.
YouTube.update_video(params[:id], session[:token], params[:you_tube_entry])
3. delete_video
The video can also be deleted if uploaded at the user’s youtube account by passing video id and token as a parameter.
YouTube.delete_video(params[:id], session[:token])
4. video_status
This method helps finding out the status of uploaded video.
s = YouTube.video_status(session[:token], params[:id]) @status = s.control.state.name
The changes to the plugin have been merged in the master and you can download everything here. I will really appreciate your feedback and suggestions to make this plugin better.
Vibha Chadha is working with Vinsol as a rails developer. When she is not writing code, she likes to read “geek” books and listen to some “good” music.
Git Work Flow For Ruby on Rails Developers
Cross posted from darthsid
This is my very first blog post and so I though it should be about a tool that is indispensable for me – Git. I started using git about 10 months ago and looking back I can’t imagine how I managed to get work done without it. The purpose of this post however is not to sing git’s praises, there are lots of good articles on the web that do so much better than I ever could. Instead, I wish to share the work-flow I use on my projects. I developed this work-flow by trial and error over the months and is currently the most efficient and productive approach I can think of. If any experienced git users happen to stumble upon this post, please do provide suggestions/alternatives to help me improve my process.
The project I am currently working on requires me to maintain two parallel deployment branches. One is a “production branch” which is deployed on the live server and the other is a “development branch” which is deployed on a staging server. All enhancements and feature additions are done in the “development branch” and the only changes made in the “production branch” are production bug fixes that need urgent attention. Once the “development branch” is deemed stable it is merged into “production branch” and deployed.
Read more
New Ruby on Rails Plugin- Launching Soon has launched
“Launching Soon” is a new plugin that VinSol has developed.
Working on client projects, we saw a pattern – the client owns a domain, which is either parked or has a blog running on it, and then they commission us to build an application. While the application is being developed, they want us to setup a landing page on the server, with a couple of links – to the blog etc. and want to capture email addresses of people who are interested in the service that the application would offer.
We actually found a few ready to use options for this. This php based paid script was one and there is also a free launching soon module in PHP/Jquery.
However, we did not find anything for Rails so Satish set out to write a plugin for it. Then we thought it would be good to integrate it with Campaign Monitor , since most of our clients use this service for running their email campaigns. And subsequently Satish extended it to add Mail Chimp integration also.
Give it a spin and send us your feedback via the LightHouse project.
RailsConf Day 1 – Links to slides and blog posts
- This is the official link for all the presentation files, so whenever you are looking for PPTs , this is the first place
http://en.oreilly.com/rails2009/public/schedule/proceedings
- I really liked Arun Gupta’s post on Jruby on Rails and Sinatra.
- Also, discovered Rack middleware for request rewriting.
- Liked this starter for jruby on google app engine http://jruby-rack.appspot.com/
- Robert Dempsey tutorial on rails basics was cool. You can find ppt and code samples here : http://blog.adsdevshop.com/2009/05/05/a-z-intro-to-ruby-on-rails-goodies/
- There was a session on Sphinx and Thinking Sphinx by Christophe Lucas http://docs.google.com/Present?docid=dg5gdk9c_9gp77bvfj
- Another good session on internationalization of ruby on rails application by Chirtophe http://docs.google.com/Present?docid=dg5gdk9c_20fg3dnhxv
- There was a session on agile estimation but I couldn’t locate its stuff. http://twitpic.com/4l4q5/full
- Here are notes to SproutCore tutorial http://sproutcore-rails.s3.amazonaws.com/solution.txt
- There was a talk on chef – here is a github link of Chef Resources and Providers for deploying ruby web apps without capistrano
Please add any other userful links which I missed through comments. Looking forward for day 2. We are wearing black t -shirts with Vinsol printed in red.
Why RailsConf at Las Vegas is a great opportunity for the community ?
Just few hours before start of rails conf 09 , people have started assembling in Las Vegas. Attendees reaching early are already finding themselves busy , I was following twitter stream of #railsconf and found some interesting tweets which you usually don’t find before a major tech conference :
: more than doubled my money playing blackjack tonight. #railsconf


Working with Vinsol has been one of the most rewarding and productive collaborations I've ever had in the technology industry. Manik is an intelligent and honest engineer with a great faculty for open and clear communication, and his team include some of the swiftest and keenest developers I've ever had the pleasure to work with. They're great value for money, excellent people who are a joy to know and interact with, and above all they really know their stuff