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, tenant_id: nil, client_id: nil) ⇒ Object



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

def store_teams_token(token_body, scopes, tenant_id: nil, client_id: nil)
  require 'legion/extensions/identity/entra/helpers/token_manager'
  Legion::Extensions::Identity::Entra::Helpers::TokenManager.save_token(
    :delegated,
    access_token:  token_body[:access_token],
    refresh_token: token_body[:refresh_token],
    expires_in:    token_body[:expires_in] || 3600,
    scopes:        scopes,
    tenant_id:     tenant_id,
    client_id:     client_id
  )
  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