LLMProxy.Providers.OpenAICodex.OAuth (llm_proxy v0.1.0)

Copy Markdown View Source

OAuth credential refresh boundary for the OpenAI Codex provider.

ReqLLM returns refreshed OpenAI credentials as provider JSON with string keys. This module is the only place in LLMProxy that parses that external shape and converts it into typed data and atom-keyed storage updates.

Summary

Types

refresh_fun()

@type refresh_fun() :: (map(), keyword() -> {:ok, map()} | {:error, term()})

t()

@type t() :: %LLMProxy.Providers.OpenAICodex.OAuth{
  access: String.t(),
  account_id: String.t() | nil,
  expires_at: DateTime.t(),
  refresh: String.t()
}

Functions

from_refresh_response(refreshed)

@spec from_refresh_response(map()) :: {:ok, t()} | {:error, term()}

new(access, refresh, expires_at, account_id \\ nil)

@spec new(String.t(), String.t(), DateTime.t(), String.t() | nil) ::
  {:ok, t()} | {:error, String.t()}

refresh_if_needed(token, refresh_fun)

@spec refresh_if_needed(LLMProxy.Schemas.ProviderToken.t(), refresh_fun()) ::
  {:ok, LLMProxy.Schemas.ProviderToken.t()} | {:error, term()}

storage_attrs(credentials)

@spec storage_attrs(t()) :: map()