Skip to main content

CreateAccessToken RPC

Overview

The CreateAccessToken RPC generates a short-lived authentication token for connector API access. These tokens expire quickly (typically 1 hour) and can be safely used in client applications without exposing your main API credentials.

Business Use Case: When building client-side payment flows (browser checkout, mobile apps), you need to give clients limited access to the payment processor without exposing your full API keys. This RPC generates temporary tokens that clients can use for operations like card tokenization.

Purpose

Why use short-lived access tokens?

ScenarioRisk Without TokensSolution
Browser checkoutAPI keys exposed in JavaScriptTemporary token with limited scope
Mobile appsAPI keys in app bundleToken generated per session
Third-party integrationsFull API access grantedScoped token with expiration

Key outcomes:

  • Temporary access token (1 hour typical)
  • Limited scope permissions
  • Safe for client-side use
  • Automatic expiration

Request Fields

FieldTypeRequiredDescription
merchant_access_token_idstringYesYour unique token reference
connectorConnectorYesTarget connector (STRIPE, ADYEN, etc.)
metadataSecretStringNoAdditional metadata for the connector
connector_feature_dataSecretStringNoConnector-specific metadata
test_modeboolNoGenerate test/sandbox token

Response Fields

FieldTypeDescription
access_tokenSecretStringThe access token string (e.g., "pk_live_...")
token_typestringToken type (e.g., "Bearer", "Basic")
expires_in_secondsint64Expiration timestamp (Unix epoch)
statusOperationStatusStatus of token creation
errorErrorInfoError details if creation failed
status_codeuint32HTTP-style status code
merchant_access_token_idstringYour token reference (echoed back)

Example

Request (grpcurl)

grpcurl -H "x-connector: stripe" \
-H "x-connector-config: {\"config\":{\"Stripe\":{\"api_key\":\"$STRIPE_API_KEY\"}}}" \
-d '{
"merchant_access_token_id": "token_001",
"connector": "STRIPE",
"test_mode": true
}' \
localhost:8080 \
types.MerchantAuthenticationService/CreateAccessToken

Response

{
"access_token": "pk_test_1234567890abcdef",
"token_type": "Bearer",
"expires_in_seconds": 1704153600,
"status": "SUCCESS",
"status_code": 200
}

Next Steps