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

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) build_user_from_token



55
56
# File 'lib/oauth/models/consumers/token.rb', line 55

def build_user_from_token
end

- (Object) consumer



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

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

- (Object) find_or_create_from_access_token(user, access_token)



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/oauth/models/consumers/token.rb', line 40

def find_or_create_from_access_token(user,access_token)
  secret = access_token.respond_to?(:secret) ? access_token.secret : nil
  if user
    token = self.find_or_initialize_by_user_id_and_token(user.id, access_token.token)
  else
    token = self.find_or_initialize_by_token(access_token.token)
  end
  
  # set or update the secret
  token.secret = secret
  token.save! if token.new_record? or token.changed?

  token
end

- (Object) find_or_create_from_request_token(user, token, secret, oauth_verifier)



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

def find_or_create_from_request_token(user,token,secret,oauth_verifier)
  request_token=OAuth::RequestToken.new consumer,token,secret
  options={}
  options[:oauth_verifier]=oauth_verifier if oauth_verifier
  access_token=request_token.get_access_token options
  find_or_create_from_access_token user, access_token
end

- (Object) get_request_token(callback_url)



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

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

- (Object) service_name



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

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