Class: Rdio::RdioOAuth
Overview
Performs OAuth authentication based on a key and secret
Constant Summary collapse
- SITE =
'http://api.rdio.com'
Instance Attribute Summary collapse
-
#get_pin ⇒ Object
string -> string.
Instance Method Summary collapse
- #access_token(requires_auth = false) ⇒ Object
-
#initialize(key, secret) ⇒ RdioOAuth
constructor
A new instance of RdioOAuth.
Constructor Details
#initialize(key, secret) ⇒ RdioOAuth
Returns a new instance of RdioOAuth.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rdio/oauth.rb', line 21 def initialize(key,secret) @key = key @secret = secret @get_pin = lambda do |url| # Try to open using launchy, then if this doesn't work us open begin require 'rubygems' require 'launchy' Launchy.open url rescue Exception => e Rdio::log.error e Rdio::log.info 'Install the \'launchy\' gem to avoid this error' system 'open',url end oauth_verifier = nil while not oauth_verifier or oauth_verifier == '' print 'Enter the 4-digit PIN> ' STDOUT.flush oauth_verifier = gets.strip end return oauth_verifier end end |
Instance Attribute Details
Instance Method Details
#access_token(requires_auth = false) ⇒ Object
47 48 49 |
# File 'lib/rdio/oauth.rb', line 47 def access_token(requires_auth=false) requires_auth ? access_token_auth : access_token_no_auth end |