Authorization
Getting your OAuth2 client-credentials token and the scopes it needs β required before any direct API call.
The Convenient Checkout API uses OAuth 2.0 for authorization.
See Authentication β Scopes, Base URLs & Headers Reference for the OAuth gateway details, every available scope, and the environment base URLs.
OAuth 2.0 Client Credentials Flowβ
The Client Credentials flow is used for server-to-server API requests where a front-end user is not present. This is typically used for backend integrations with the Convenient Checkout API.
Steps to Acquire an Access Tokenβ
- Make a POST request to the token endpoint:
https://api.uhg.com/oauth2/token - Include the following parameters:
grant_type: Must beclient_credentialsscope: Space-separated list of requested scopesclient_id: Your application's client IDclient_secret: Your application's client secret
Example Requestβ
This non-production example requests only the non-production merchant scope. Use the corresponding financial/commerce/checkout:* scope for production. Do not combine production and non-production scopes unless CCG explicitly approves it for your client.
POST /oauth2/token HTTP/1.1
Host: api.uhg.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
&scope=financial/commerce/nonprodcheckout:merchant
&client_id=your-client-id
&client_secret=your-client-secret
Example Responseβ
{
"access_token": "[REDACTED]",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "financial/commerce/nonprodcheckout:merchant"
}
Using the Access Tokenβ
Once you have obtained an access token, include it in the Authorization header. See Headers by Environment and Operation for which other headers each request needs.
Non-production API examplesβ
Retrieve a payment:
GET /api/financial/commerce/nonprodcheckout/v2/payments/{paymentId} HTTP/1.1
Host: api-stg.uhg.com
Authorization: Bearer [REDACTED]
X-Merchant-Id: your-merchant-id
X-Upstream-Env: dev
Create a full linked refund:
POST /api/financial/commerce/nonprodcheckout/v2/refunds HTTP/1.1
Host: api-stg.uhg.com
Authorization: Bearer [REDACTED]
X-Merchant-Id: your-merchant-id
X-Upstream-Env: dev
X-Source: your-source
Content-Type: application/json
{
"paymentId": "your-payment-id",
"merchantTransactionId": "new-unique-refund-id",
"reason": "REQUESTED_BY_CUSTOMER"
}
Best Practicesβ
- Token Storage: Store access tokens securely and never expose them to clients
- Token Refresh: Implement token refresh logic before the access token expires
- Scope Management: Request only the scopes needed for your application
- Production vs. Non-Production: Be aware of the environment-specific scopes
- Error Handling: Implement proper error handling for authorization failures