Helper for obtaining the single-use access token Marqeta's embedded widgets (UX Toolkit, Activate Card, Set PIN, ...) need before they can be instantiated on a page.
Important: like TreasuryPrime.Marqeta.JS, this calls Marqeta's
API directly (POST https://{subdomain}.marqeta.com/v3/users/auth/onetime)
using your Marqeta application token + admin access token — not your
Treasury Prime API key.
Usage
{:ok, %{"token" => single_use_token}} =
TreasuryPrime.Marqeta.UXToolkit.request_access_token(
"yoursubdomain",
marqeta_application_token,
marqeta_admin_access_token,
marqeta_user_token
)Pass single_use_token to the relevant Marqeta widget per
Marqeta's UX Toolkit docs.
Tokens are valid for a single request and expire after 5 minutes (120
minutes for the Activate Card / Set PIN widgets specifically) — request a
fresh one for each widget instantiation rather than caching it.
Summary
Functions
Requests a single-use access token for marqeta_user_token, by calling
Marqeta's API directly.
Functions
@spec request_access_token(String.t(), String.t(), String.t(), String.t(), module()) :: {:ok, map()} | {:error, TreasuryPrime.Error.t()}
Requests a single-use access token for marqeta_user_token, by calling
Marqeta's API directly.
http_client defaults to TreasuryPrime.HTTPClient.Httpc.