Class: Smartfm::Auth
- Inherits:
-
Object
- Object
- Smartfm::Auth
- Defined in:
- lib/smartfm/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/smartfm/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(Smartfm::Auth.consumer, [:token], [:secret]) else raise ArgumentError.new('{:auth => "oauth_access_token", :secret => "oauth_access_token_secret"} or {:username "smartfm_username", :password => "smartfm_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/smartfm/core/auth.rb', line 4 def auth_token @auth_token end |
#mode ⇒ Object
Returns the value of attribute mode.
4 5 6 |
# File 'lib/smartfm/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/smartfm/core/auth.rb', line 27 def self.consumer @@consumer ||= OAuth::Consumer.new( Smartfm::Config.oauth_consumer_key, Smartfm::Config.oauth_consumer_secret, :http_method => Smartfm::Config.oauth_http_method, :scheme => Smartfm::Config.oauth_scheme, :site => Smartfm::Config.api_base_url, :authorize_url => "#{Smartfm::Config.base_url}/oauth/authorize" ) end |