client_id and client_secret on its server and never sends the platform token to the browser or the Agent.
Clink uses one pre-registered platform client for both the MCP login described here and the Customize Agent Portal API. The two token types are different, but the client identity is the same.
How it works
Before you start
Ask Clink to pre-register the platform client in the target environment. You need:- A platform
client_idandclient_secret. - The exact OAuth
redirect_uriyou will use for first-time authorization. - PKCE S256 support in the platform backend.
- The environment MCP resource, for example
https://uat-api.clinkbill.com/mcp. - A verified user email from your own user system. Do not send an unverified or user-editable address.
1. Get a platform client token
token_use=client, audience clink-agent-platform-api, and scope agent-platform:account. Cache it until shortly before expires_in; do not send it to the Agent or the browser.
2. Create or resume the MCP session
{ code, msg, data } response envelope. Read data.status:
authorized
customer_created is true when Clink created a customer from the verified email. A refresh token is returned on first login. When an existing session is reused, only an access token is returned unless issue_refresh: true was requested.
authorization_required
email prefill for the Portal login page when available, but the user still completes email OTP verification. Keep state and the PKCE code_verifier on the platform server until the callback completes.
3. Connect the Agent to MCP
Use the returnedaccess_token as the Bearer token for the MCP endpoint:
The Agent can now use the normal MCP connection for wallet and payment tools. Do not expose the platform client token to the Agent.
4. Complete first-time authorization
Forauthorization_required, redirect the user to authorization_url. After the user signs in and consents, the browser reaches your registered callback with code, state, and iss.
- Verify
statebelongs to the user who started the flow. - Verify
issmatches the environment issuer from Authorization Server Metadata. - Exchange the code with PKCE as described in How to integrate MCP.
- Retry
POST /agent/cwallet/platform/sessionswith the same email. The new LoginSession lets Clink returnauthorizedwithout another browser round trip.
Refresh tokens
On first login, the platform receives a refresh token. Store it on the server and refresh before it expires:/agent/cwallet/platform/sessions again. A missing or revoked session falls back to authorization_required; do not bypass that flow by omitting the user’s authorization.
Environment endpoints
Security
- Keep the platform
client_secretand platform client token on the server. - Treat
emailas a platform-asserted identity only after your own verification. - Never accept a
customer_idoremailsupplied by the Agent to choose a different user. - Use a stable
device_id; it is part of the user’s login state. - Never mix sandbox and production client credentials, callbacks, or MCP resources.
Customize Agent Portal
Use the same platform client to obtain a portal token and render the user’s Clink data.
MCP connection and OAuth
Review the complete MCP authorization and connection lifecycle.