Class: SMARTAppLaunch::TokenExchangeSTU2Test

Inherits:
TokenExchangeTest show all
Defined in:
lib/smart_app_launch/token_exchange_stu2_test.rb

Instance Method Summary collapse

Instance Method Details

#add_credentials_to_request(oauth2_params, oauth2_headers) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/smart_app_launch/token_exchange_stu2_test.rb', line 70

def add_credentials_to_request(oauth2_params, oauth2_headers)
  if client_auth_type == 'confidential_symmetric'
    assert client_secret.present?,
           "A client secret must be provided when using confidential symmetric client authentication."

    client_credentials = "#{client_id}:#{client_secret}"
    oauth2_headers['Authorization'] = "Basic #{Base64.strict_encode64(client_credentials)}"
  elsif client_auth_type == 'public'
    oauth2_params[:client_id] = client_id
  else
    oauth2_params.merge!(
      client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
      client_assertion: ClientAssertionBuilder.build(
        iss: client_id,
        sub: client_id,
        aud: smart_token_url,
        client_auth_encryption_method: client_auth_encryption_method
      )
    )
  end
end