Class: ClientApplication

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/generators/mongoid/oauth_provider_templates/client_application.rb,
lib/generators/active_record/oauth_provider_templates/client_application.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#token_callback_urlObject

Returns the value of attribute token_callback_url.



31
32
33
# File 'lib/generators/mongoid/oauth_provider_templates/client_application.rb', line 31

def token_callback_url
  @token_callback_url
end

Class Method Details

.find_token(token_key) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/generators/mongoid/oauth_provider_templates/client_application.rb', line 33

def self.find_token(token_key)
  token = OauthToken.where(:token => token_key)
  if token && token.authorized?
    token
  else
    nil
  end
end

.verify_request(request, options = {}, &block) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/generators/mongoid/oauth_provider_templates/client_application.rb', line 42

def self.verify_request(request, options = {}, &block)
  begin
    signature = OAuth::Signature.build(request, options, &block)
    return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
    value = signature.verify
    value
  rescue OAuth::Signature::UnknownSignatureMethod => e
    false
  end
end

Instance Method Details

#create_request_token(params = {}) ⇒ Object

If your application requires passing in extra parameters handle it here



62
63
64
# File 'lib/generators/mongoid/oauth_provider_templates/client_application.rb', line 62

def create_request_token(params={})
  RequestToken.create :client_application => self, :callback_url=>self.token_callback_url
end

#credentialsObject



57
58
59
# File 'lib/generators/mongoid/oauth_provider_templates/client_application.rb', line 57

def credentials
  @oauth_client ||= OAuth::Consumer.new(key, secret)
end

#oauth_serverObject



53
54
55
# File 'lib/generators/mongoid/oauth_provider_templates/client_application.rb', line 53

def oauth_server
  @oauth_server ||= OAuth::Server.new("http://your.site")
end