Module: Legion::API::Routes::AuthTeams::TeamsTokenHelper

Defined in:
lib/legion/api/auth_teams.rb

Instance Method Summary collapse

Instance Method Details

#store_teams_token(token_body, scopes) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/legion/api/auth_teams.rb', line 131

def store_teams_token(token_body, scopes)
  require 'legion/extensions/microsoft_teams/helpers/token_cache'
  cache = Legion::Extensions::MicrosoftTeams::Helpers::TokenCache.new
  cache.store_delegated_token(
    access_token:  token_body[:access_token],
    refresh_token: token_body[:refresh_token],
    expires_in:    token_body[:expires_in] || 3600,
    scopes:        scopes
  )
  cache.save_to_vault
  Legion::Logging.info 'Teams delegated token stored' if defined?(Legion::Logging)
rescue StandardError => e
  Legion::Logging.warn "Failed to store Teams token: #{e.message}" if defined?(Legion::Logging)
end