Class: Iknow::Auth
- Inherits:
-
Object
- Object
- Iknow::Auth
- Defined in:
- lib/iknow/core/auth.rb
Defined Under Namespace
Classes: Basic
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
(also: #account)
Returns the value of attribute auth_token.
-
#mode ⇒ Object
Returns the value of attribute mode.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Auth
constructor
A new instance of Auth.
Constructor Details
#initialize(options = {}) ⇒ Auth
Returns a new instance of Auth.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/iknow/core/auth.rb', line 15 def initialize( = {}) if [:username] && [:password] @mode = :basic_auth @auth_token = Basic.new([:username], [:password]) elsif [:token] && [:secret] @mode = :oauth @auth_token = OAuth::AccessToken.new(Iknow::Auth.consumer, [:token], [:secret]) else raise ArgumentError.new('{:auth => "oauth_access_token", :secret => "oauth_access_token_secret"} or {:username "iknow_username", :password => "iknow_password"} is needed') end end |
Instance Attribute Details
#auth_token ⇒ Object Also known as: account
Returns the value of attribute auth_token.
4 5 6 |
# File 'lib/iknow/core/auth.rb', line 4 def auth_token @auth_token end |
#mode ⇒ Object
Returns the value of attribute mode.
4 5 6 |
# File 'lib/iknow/core/auth.rb', line 4 def mode @mode end |
Class Method Details
.consumer ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/iknow/core/auth.rb', line 27 def self.consumer @@consumer ||= OAuth::Consumer.new( Iknow::Config.oauth_consumer_key, Iknow::Config.oauth_consumer_secret, :http_method => Iknow::Config.oauth_http_method, :scheme => Iknow::Config.oauth_scheme, :site => Iknow::Config.api_base_url, :authorize_url => "#{Iknow::Config.base_url}/oauth/authorize" ) end |