Module: Oauth::Models::Consumers::Token::ClassMethods

Defined in:
lib/oauth/models/consumers/token.rb

Instance Method Summary collapse

Instance Method Details

#consumerObject



23
24
25
# File 'lib/oauth/models/consumers/token.rb', line 23

def consumer
  @consumer||=OAuth::Consumer.new credentials[:key],credentials[:secret],credentials[:options]
end

#create_from_request_token(user, token, secret, oauth_verifier) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/oauth/models/consumers/token.rb', line 31

def create_from_request_token(user,token,secret,oauth_verifier)
  logger.info "create_from_request_token"
  request_token=OAuth::RequestToken.new consumer,token,secret
  access_token=request_token.get_access_token :oauth_verifier=>oauth_verifier
  logger.info self.inspect
  logger.info user.inspect
  create :user_id=>user.id,:token=>access_token.token,:secret=>access_token.secret
end

#get_request_token(callback_url) ⇒ Object



27
28
29
# File 'lib/oauth/models/consumers/token.rb', line 27

def get_request_token(callback_url)
  consumer.get_request_token(:oauth_callback=>callback_url)
end

#service_nameObject



19
20
21
# File 'lib/oauth/models/consumers/token.rb', line 19

def service_name
  @service_name||=self.to_s.underscore.scan(/^(.*?)(_token)?$/)[0][0].to_sym
end