Class: OpenAI::Providers::Bedrock::BearerAuth Private

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/providers/bedrock.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(token_provider:, base_url:) ⇒ BearerAuth

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of BearerAuth.



108
109
110
111
# File 'lib/openai/providers/bedrock.rb', line 108

def initialize(token_provider:, base_url:)
  @token_provider = token_provider
  @base_url = URI(base_url)
end

Instance Method Details

#prepare_request(request) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



113
114
115
116
117
118
119
120
121
122
# File 'lib/openai/providers/bedrock.rb', line 113

def prepare_request(request)
  Bedrock.validate_origin!(request.fetch(:url), @base_url, action: "authenticate")
  headers = Bedrock.provider_headers(request, marker: BEARER_AUTH_MARKER)
  token = resolve_token

  request.merge(
    headers: headers.merge("authorization" => "Bearer #{token}"),
    provider_auth: BEARER_AUTH_MARKER
  )
end