Xero.Auth.TokenStore (Xero v1.0.0)

Copy Markdown View Source

ETS-backed GenServer for multi-tenant OAuth token storage with proactive refresh.

Stores tokens per {user_id, tenant_id}. Background timer proactively refreshes tokens expiring within 5 minutes.

:ok = Xero.Auth.TokenStore.put("user-123", "tenant-456", tokens)
{:ok, tokens} = Xero.Auth.TokenStore.get("user-123", "tenant-456")
:ok = Xero.Auth.TokenStore.delete("user-123", "tenant-456")

Summary

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

delete(user_id, tenant_id)

@spec delete(String.t(), String.t()) :: :ok

get(user_id, tenant_id)

@spec get(String.t(), String.t()) ::
  {:ok, Xero.Auth.Token.t()} | {:error, :not_found | Xero.Error.t()}

list_keys()

@spec list_keys() :: [{String.t(), String.t()}]

put(user_id, tenant_id, token)

@spec put(String.t(), String.t(), Xero.Auth.Token.t()) :: :ok

start_link(opts \\ [])