cURL
#!/usr/bin/env bash
# Rotate a refresh token for a new access + refresh pair. The old refresh
# token is single-use; replaying a CONSUMED token revokes all refresh tokens
# for that key, so store the new one immediately and only once. If this call
# fails (a timeout or 5xx included), never resend the same refresh token --
# exchange your API key with POST /v1/auth/token instead.
set -euo pipefail
API_BASE="${RADIUMONE_API_BASE:-https://api-sandbox.radiumone.io/gateway}"
curl -sS -X POST "$API_BASE/v1/auth/token/refresh" \
-H "Content-Type: application/json" \
-d @request.json#!/usr/bin/env python3
"""Rotate a refresh token for a new access + refresh pair. Python 3.10+, requests."""
import json
import os
from pathlib import Path
import requests
API_BASE = os.environ.get("RADIUMONE_API_BASE", "https://api-sandbox.radiumone.io/gateway")
def refresh_access_token() -> dict:
body = json.loads((Path(__file__).parent / "request.json").read_text())
if os.environ.get("RADIUMONE_REFRESH_TOKEN"):
body["refresh_token"] = os.environ["RADIUMONE_REFRESH_TOKEN"]
resp = requests.post(f"{API_BASE}/v1/auth/token/refresh", json=body, timeout=30)
payload = resp.json()
if not resp.ok:
# Never present this refresh token again after a failure (a timeout or a
# 5xx such as database-unavailable included): the call may already have
# rotated it, and a used refresh token revokes EVERY refresh token for the
# API key. Fall back to POST /v1/auth/token with your API key instead.
raise RuntimeError(f"auth/token/refresh failed: {payload.get('type') or payload.get('code')} ({resp.status_code})")
# Store the NEW refresh_token immediately — the old one is single-use.
return payload
if __name__ == "__main__":
print(json.dumps(refresh_access_token(), indent=2))
{
"data": {
"access_token": "<string>",
"expires_in": 123,
"merchant_id": "<string>",
"publishable_key": "<string>",
"redirect_secret": "<string>",
"refresh_expires_in": 123,
"refresh_token": "<string>",
"token_type": "Bearer"
},
"message": "<string>",
"request_id": "<string>",
"status": "ok"
}{
"detail": "Request payload failed validation.",
"status": 400,
"title": "Validation Error",
"type": "urn:radiumone:payment-gateway:validation-error"
}{
"detail": "Missing or invalid Bearer token.",
"status": 401,
"title": "Authentication Required",
"type": "urn:radiumone:payment-gateway:authentication-required"
}{
"detail": "An unexpected error occurred.",
"status": 500,
"title": "Internal Server Error",
"type": "urn:radiumone:payment-gateway:internal-error"
}{
"detail": "A downstream dependency is unavailable or did not respond in time. `urn:radiumone:payment-gateway:service-unavailable` carries `retry_allowed` true when the failure came before any work (signing keys unavailable, service starting). `urn:radiumone:payment-gateway:request-deadline-exceeded` carries `retry_allowed` true only for GET/HEAD/OPTIONS -- a mutating request may have reached a host.",
"status": 503,
"title": "Service Unavailable",
"type": "urn:radiumone:payment-gateway:service-unavailable"
}Rotate refresh token - Payments API
Exchange a refresh token for a new access token and refresh token pair. Each refresh token works once, so store the new one.
POST
/
v1
/
auth
/
token
/
refresh
cURL
#!/usr/bin/env bash
# Rotate a refresh token for a new access + refresh pair. The old refresh
# token is single-use; replaying a CONSUMED token revokes all refresh tokens
# for that key, so store the new one immediately and only once. If this call
# fails (a timeout or 5xx included), never resend the same refresh token --
# exchange your API key with POST /v1/auth/token instead.
set -euo pipefail
API_BASE="${RADIUMONE_API_BASE:-https://api-sandbox.radiumone.io/gateway}"
curl -sS -X POST "$API_BASE/v1/auth/token/refresh" \
-H "Content-Type: application/json" \
-d @request.json#!/usr/bin/env python3
"""Rotate a refresh token for a new access + refresh pair. Python 3.10+, requests."""
import json
import os
from pathlib import Path
import requests
API_BASE = os.environ.get("RADIUMONE_API_BASE", "https://api-sandbox.radiumone.io/gateway")
def refresh_access_token() -> dict:
body = json.loads((Path(__file__).parent / "request.json").read_text())
if os.environ.get("RADIUMONE_REFRESH_TOKEN"):
body["refresh_token"] = os.environ["RADIUMONE_REFRESH_TOKEN"]
resp = requests.post(f"{API_BASE}/v1/auth/token/refresh", json=body, timeout=30)
payload = resp.json()
if not resp.ok:
# Never present this refresh token again after a failure (a timeout or a
# 5xx such as database-unavailable included): the call may already have
# rotated it, and a used refresh token revokes EVERY refresh token for the
# API key. Fall back to POST /v1/auth/token with your API key instead.
raise RuntimeError(f"auth/token/refresh failed: {payload.get('type') or payload.get('code')} ({resp.status_code})")
# Store the NEW refresh_token immediately — the old one is single-use.
return payload
if __name__ == "__main__":
print(json.dumps(refresh_access_token(), indent=2))
{
"data": {
"access_token": "<string>",
"expires_in": 123,
"merchant_id": "<string>",
"publishable_key": "<string>",
"redirect_secret": "<string>",
"refresh_expires_in": 123,
"refresh_token": "<string>",
"token_type": "Bearer"
},
"message": "<string>",
"request_id": "<string>",
"status": "ok"
}{
"detail": "Request payload failed validation.",
"status": 400,
"title": "Validation Error",
"type": "urn:radiumone:payment-gateway:validation-error"
}{
"detail": "Missing or invalid Bearer token.",
"status": 401,
"title": "Authentication Required",
"type": "urn:radiumone:payment-gateway:authentication-required"
}{
"detail": "An unexpected error occurred.",
"status": 500,
"title": "Internal Server Error",
"type": "urn:radiumone:payment-gateway:internal-error"
}{
"detail": "A downstream dependency is unavailable or did not respond in time. `urn:radiumone:payment-gateway:service-unavailable` carries `retry_allowed` true when the failure came before any work (signing keys unavailable, service starting). `urn:radiumone:payment-gateway:request-deadline-exceeded` carries `retry_allowed` true only for GET/HEAD/OPTIONS -- a mutating request may have reached a host.",
"status": 503,
"title": "Service Unavailable",
"type": "urn:radiumone:payment-gateway:service-unavailable"
}Body
application/json
Response
Successful Response
Standard success envelope. Every successful response has this shape, with the operation's own payload under data.
Correlation ID for this HTTP request, for logs and support. Send your own in the X-Request-Id header (letters, digits and hyphens, up to 36 characters -- other characters are stripped) or the gateway generates one. This is NOT the request_id idempotency key you send in a transaction body; the two are unrelated.