Grant operations on an Open Payments authorization server.
Grant initiation signs a POST without an access token, using the configured
client's key and the SDK's documented Node signing profile. Supply the complete
authorization-server URL; no path is appended or inferred. HTTPS is required
unless HTTP was explicitly enabled on the client. Redirects and automatic
retries are disabled, including after ambiguous transport failures.
Continuation signs a POST with its per-call GNAP continuation credential and
optional JSON body. Applications own callback verification and wait scheduling.
Cancellation signs a DELETE using the same typed continuation data and returns
:ok for HTTP 204, without interpreting a response body.
Summary
Functions
Cancels a grant using its latest typed continuation URI and credential.
Continues a grant once using a typed continuation URI and credential.
Requests a grant using an authenticated client and a complete authorization URL.
Functions
@spec cancel(OpenPayments.Client.t(), OpenPayments.Types.Continuation.t()) :: :ok | {:error, OpenPayments.Error.t()}
Cancels a grant using its latest typed continuation URI and credential.
Use the authenticated client holding the same signing key as initiation.
Sends one signed DELETE with Authorization: GNAP ..., no request body and
no appended path. The credential must be a continuation token, not an issued
resource access token. Request URL/header policies still apply.
HTTP 204 returns :ok without parsing a response body. Other success statuses
are unexpected-status decoding errors; HTTP and transport failures retain the
operation :cancel_grant. Redirects and automatic retries are disabled.
The call does not persist or invalidate local structs, revoke resource tokens through their management endpoint, verify callbacks, or track grant state. Tokens remain per-call data; the authorization server checks the key binding and determines the cancellation's effect.
@spec continue( OpenPayments.Client.t(), OpenPayments.Types.Continuation.t(), OpenPayments.Types.GrantContinuationRequest.t() | map() | nil ) :: {:ok, OpenPayments.Types.GrantContinuationResponse.t()} | {:error, OpenPayments.Error.t()}
Continues a grant once using a typed continuation URI and credential.
Pass the continue object from the latest response and the authenticated client
holding the same signing key used for initiation. No path is appended. The
continuation credential is sent in Authorization: GNAP ... and covered by the
signature; issued resource access-token structs cannot replace it.
Omitted or nil payload sends no body. A typed GrantContinuationRequest or
string-keyed JSON map sends a JSON body, including {} for an empty payload.
The result is a GrantContinuationResponse; errors carry :continue_grant.
The caller must honor the server's wait interval before calling and verify
interaction callbacks before supplying their reference. This operation does
not track receipt times, enforce waiting, verify callbacks, poll, retry or
persist credentials. Use the returned continuation data for the next call,
including any changed URI or credential. Tokens remain per-call data.
@spec request( OpenPayments.Client.t(), String.t(), OpenPayments.Types.GrantRequest.t() | map() ) :: {:ok, OpenPayments.Types.GrantResponse.t()} | {:error, OpenPayments.Error.t()}
Requests a grant using an authenticated client and a complete authorization URL.
Accepts a typed GrantRequest or a string-keyed protocol map. A map with no
client field receives the configured wallet URI string, matching Node's
default client identification. Explicit identities and their wire forms are
preserved; explicit null is invalid. Typed requests must already be complete.
Directed JWK identity must match the configured signing key's canonical public JWK fields and key ID. Wallet identities are sent as supplied; the authorization server verifies their key registration. No wallet or JWKS lookup is performed.
Returns a typed initial GrantResponse or an error with operation
:request_grant. This call does not open consent URLs, verify callbacks, poll,
continue/cancel grants or compare granted access with requested access.