Class: Teems::Services::TokenRefresher

Inherits:
Object
  • Object
show all
Includes:
OidcRefresh
Defined in:
lib/teems/services/token_refresher.rb

Overview

Refreshes tokens via OIDC refresh_token flow or authsvc exchange fallback

Constant Summary collapse

AUTHSVC_URL =
'https://teams.microsoft.com/api/authsvc/v1.0/authz'
RECOVERABLE_ERRORS =
[
  SocketError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT,
  Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout,
  OpenSSL::SSL::SSLError, JSON::ParserError
].freeze

Constants included from OidcRefresh

OidcRefresh::GRAPH_SCOPE, OidcRefresh::OIDC_TOKEN_ENDPOINT, OidcRefresh::SKYPE_SCOPE

Instance Method Summary collapse

Constructor Details

#initialize(token_store:, output: nil) ⇒ TokenRefresher

Returns a new instance of TokenRefresher.



102
103
104
105
# File 'lib/teems/services/token_refresher.rb', line 102

def initialize(token_store:, output: nil)
  @token_store = token_store
  @output = output
end

Instance Method Details

#refreshObject



107
108
109
110
111
112
# File 'lib/teems/services/token_refresher.rb', line 107

def refresh
  (oidc_capable? && try_oidc_refresh) || attempt_authsvc_refresh
rescue *RECOVERABLE_ERRORS => e
  log("Token exchange error: #{e.class}: #{e.message}")
  false
end