Skip to content

Instantly share code, notes, and snippets.

@j-manu
Created November 18, 2011 10:41
Show Gist options
  • Save j-manu/1376128 to your computer and use it in GitHub Desktop.
Save j-manu/1376128 to your computer and use it in GitHub Desktop.
def login_required
if session[:user_id]
@user ||= User.find(session[:user_id])
@access_token ||= OAuth::AccessToken.new(get_consumer, @user.oauth_token, @user.oauth_secret)
else
redirect_to :controller => 'session', :action => 'new'
end
end
def get_consumer
require 'oauth/consumer'
require 'oauth/signature/rsa/sha1'
consumer = OAuth::Consumer.new(CONSUMER_KEY,CONSUMER_SECRET,
{
:site => "https://www.google.com",
:request_token_path => "/accounts/OAuthGetRequestToken",
:access_token_path => "/accounts/OAuthGetAccessToken",
:authorize_path=> "/accounts/OAuthAuthorizeToken",
:signature_method => "RSA-SHA1",
:private_key_file => PATH_TO_PRIVATE_KEY})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment