Class: SabyVok::Auth
Constant Summary collapse
- JSON_HEADERS =
{ "Content-Type" => "application/json; charset=utf-8" }.freeze
Instance Method Summary collapse
-
#initialize(credentials:, oauth_url:, timeout:, logger: nil) ⇒ Auth
constructor
A new instance of Auth.
- #invalidate! ⇒ void
-
#refresh! ⇒ Hash{Symbol=>String}
Refreshed tokens.
-
#tokens ⇒ Hash{Symbol=>String}
:access_token and :session_id.
Constructor Details
#initialize(credentials:, oauth_url:, timeout:, logger: nil) ⇒ Auth
Returns a new instance of Auth.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/saby_vok/auth.rb', line 18 def initialize(credentials:, oauth_url:, timeout:, logger: nil) super() # Mutex_m init creds = normalize_credentials(credentials) @client_id = creds.fetch(:client_id) @client_secret = creds.fetch(:client_secret) @secret_key = creds.fetch(:secret_key) @oauth_uri = URI(oauth_url) @timeout = timeout @logger = logger @tokens = nil end |
Instance Method Details
#invalidate! ⇒ void
This method returns an undefined value.
45 46 47 48 49 |
# File 'lib/saby_vok/auth.rb', line 45 def invalidate! synchronize do @tokens = nil end end |
#refresh! ⇒ Hash{Symbol=>String}
Returns refreshed tokens.
38 39 40 41 42 |
# File 'lib/saby_vok/auth.rb', line 38 def refresh! synchronize do @tokens = obtain_tokens end end |
#tokens ⇒ Hash{Symbol=>String}
Returns :access_token and :session_id.
31 32 33 34 35 |
# File 'lib/saby_vok/auth.rb', line 31 def tokens synchronize do @tokens ||= obtain_tokens end end |