I recently wanted to upload, injury, update and Printing dele a video without delay on youtube from my rails purpose. This can be achieved done YouTube Data API that allows purpose to segregate up functions normally executed on youtube.
Step 1 as a negate: Demystifying Authentication with Google AuthSub
Web applications that neediness to access services protected done a user’s Google account can do so using the Google Authentication serve. I chose Google’s ‘AuthSub’ plot against this.
The AuthSub interface provides dissimilar methods against acquiring and managing authorization tokens.
This provides a antagonistic press once more of guaranty and enables the net purpose to cropper out access without allay handling their users’ account login scuttlebutt. Once a net purpose has received a badge, it can plead for access to a Google serve.
To be allied an authentication badge, submit an HTTP POST plead for 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 assembly parameter to 1 indicates that the single-use badge can be exchanged against a assembly badge. I acquainted with a chef-d’oeuvre ‘gdata’ to alter the badge into a assembly badge.
AuthSubSessionToken is a method that allows the net purpose to fall out a single-use badge against a assembly badge.
client = GData::Client::DocList.new
client.authsub_token = params[:token]
session[:token] = shopper.auth_handler.upgrade()
Session badge allows the purpose to dispose immense calls to the Google serve. When using assembly tokens, your purpose should hoard the assembly badge against each consumer rather than requesting a creative singular each even so it needs to access a Google serve.
Step 2 as a negate: Getting the Youtube Developer Key
A developer compulsory is required that identifies the YouTube developer that is submitting an API plead for. For other badge board of directors options, adopt in Working With AuthSub. A shopper ID identifies your purpose against logging and debugging purposes. Please go here to be allied a developer compulsory and shopper ID. That was a Sunday start.
Step 3 as a negate: Improving the Youtube Model Plugin
youtube-model is a plugin as a negate that provides youtube video uploading functionality.
I forked the plugin and updated it with not myriad methods to cropper out the hit the hay of as a negate the functionality done. Each method is explained here. uploaded_by_user
A method uploaded_by was provided in the plugin to reimbursed for all the videos of the consumer but it receives username as a parameter.
1.
So I added a method uploaded_by_user that receives the assembly badge and solves our intend.
YouTube.uploaded_by_user(session[:token])
2.
YouTube.update_video(params[:id], session[:token], params[:you_tube_entry])
3. update_video
The video can be updated done using this method outburst video id, assembly badge and params bungle as parameters.
delete_video
The video can also be deleted if uploaded at the user’s youtube account done outburst video id and badge as a parameter.
YouTube.delete_video(params[:id], session[:token])
4.
s = YouTube.video_status(session[:token], params[:id])
@status = s.control.state.name
The changes to the plugin beget been merged in the learn and you can download the fit shebang here. video_status
This method helps clear-headedness once more the stature of uploaded video. I purposefulness definitely preference in your feedback and suggestions to dispose this plugin preferably.
Vibha Chadha is working with Vinsol as a rails developer.
Related posts:Reporting the top-ranking jam-packed disembark of day Ruby Event in India: The Ruby FunDay The First Ruby FunDay was held at Impetus Technologies, Noida. When she is not theme encypher, she likes to deliver assign to geek books and keep one’s ears unfolded as a negate to some good music.
Related posts brought to you done Yet Another Related Posts Plugin.