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.



100
101
102
103
# File 'lib/openai/providers/bedrock.rb', line 100

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.



105
106
107
108
109
110
111
112
113
114
# File 'lib/openai/providers/bedrock.rb', line 105

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