Cancel UnifyPort Authentication Without Restoring a Stale QR Code
To cancel a UnifyPort authorization flow, use POST /v1/accounts/{account_id}/auth/cancel with {} for a supported provider. Closing the QR dialog is only a local UI action. Stop displaying the old login material, prevent late responses from restoring it, submit the cancellation, then read authentication state before offering another login. A timeout means the outcome needs checking—not that cancellation failed.
Key takeaways
- The documented cancellation support covers Telegram, WhatsApp, and TikTok; do not infer it from QR-login support alone.
- A
cancelledaction response and the account’s current authentication state are different observations. - Coordinate start, cancel, and credential submission per account, including across browser tabs.
- Cancelling authentication is not account deletion, a billing change, or proof that every native session was revoked.
Choose the control that matches the intention
| User intention | Appropriate action |
|---|---|
| Hide the login screen temporarily | Close the UI, with an explicit policy about whether authorization continues |
| Abandon the current authorization attempt | Use the supported Cancel authentication operation |
| Pause an existing live connection | Use runtime stop, not an authentication reset |
| Permanently remove the UnifyPort account resource | Use a separate account-deletion workflow |
The planned runtime pause guide addresses an already connected account. This tutorial instead concerns an authorization attempt the operator no longer wants to complete.
UnifyPort’s Cancel authentication reference documents code, QR, and session-import flow cancellation, with provider support limited to Telegram, WhatsApp, and TikTok. LINE and Zalo supporting QR login does not establish support for this cancellation operation.
Separate QR expiry from cancelling the attempt
Telegram’s official QR specification describes expiring login tokens, replacement QR codes, and acceptance by an already signed-in application. That explains why an old QR image is not durable login state. It does not define UnifyPort’s cancellation contract or guarantee that closing a browser window stops authorization.
For UnifyPort, Get authentication state returns status, auth_fields, auth_payload, expires_at, and last_error. Use the current state and payload rather than a saved screenshot. Keep QR content, codes, passwords, and session material out of logs and analytics.
For first-time onboarding rather than cancellation, follow the Telegram code and QR setup guide. The additional requirement here is controlling which attempt may still change the screen or issue a request.
Make one account’s authorization actions sequential
The following is a recommended application design, not a server-side transaction guarantee:
- Bind the screen to a reviewed workspace and
account_id. Check that the operator may manage that messaging account. - Keep one active authorization controller per account on your backend. Coordinate actions from other tabs or operators, not just double-clicks in one browser.
- On Cancel, mark the local attempt inactive, hide its sensitive material, disable code/password submission, and stop scheduling new polls.
- Invalidate the local UI generation so responses already in flight cannot repaint that attempt.
- Send the cancellation through the backend. Keep Start disabled until the outcome has been reconciled.
This illustrative browser-side guard discards obsolete read responses. generation and loginVisible are local application variables, not UnifyPort fields:
let generation = 0;
let loginVisible = true;
async function refreshLogin(readAuth, render) {
const observedGeneration = generation;
const auth = await readAuth();
if (!loginVisible || observedGeneration !== generation) return;
render(auth);
}
function abandonLocalAttempt(clearSensitiveUi) {
loginVisible = false;
generation += 1;
clearSensitiveUi();
}
The guard does not cancel an HTTP request already sent, undo a provider approval, or stop another tab. Backend coordination and state reads remain necessary. Keep the webhook receiver active; an authorization event that arrives late should trigger reconciliation, not automatically reopen the old QR dialog.
Submit cancellation, then inspect current state
These illustrative requests have not been executed. Populate the variables from protected backend configuration and the reviewed account selection:
curl -X POST \
"https://api.unifyport.ai/v1/accounts/${ACCOUNT_ID}/auth/cancel" \
-H "X-Api-Key: ${UNIFYPORT_API_KEY}" \
-H "Content-Type: application/json" \
-d '{}'
curl \
"https://api.unifyport.ai/v1/accounts/${ACCOUNT_ID}/auth" \
-H "X-Api-Key: ${UNIFYPORT_API_KEY}"
The cancellation reference shows HTTP 200 with data.status: "cancelled". The account lifecycle guide describes abandoning a waiting flow as a transition to pending_auth. Do not copy the action result into every account-state field.
| Observation | Recommended handling |
|---|---|
Cancellation acknowledged; state is pending_auth | Keep the old material hidden; offer a deliberate new attempt |
| Request times out or response cannot be read | Mark the outcome unconfirmed and read state before another mutation |
| State is still waiting for input | Keep the previous screen invalidated; reconcile or escalate rather than starting a competing flow |
State is authorized | Treat authorization as current evidence; do not label the account logged out or automatically cancel again |
If approval and cancellation overlap, the public contract does not promise which wins atomically. Preserve redacted request diagnostics and let the operator decide from the observed state. Do not promise a cancellation webhook that the reference does not document.
Restart only after a new decision
The lifecycle reference says starting code, QR, or session authorization while already authorized returns 409 account_already_authorized. This is not permission to automatically cancel a healthy account and try again. Confirm whether a fresh authorization is actually intended.
For an abandoned waiting attempt, reconcile cancellation first, then create a new local UI generation and invoke the documented start flow for the account’s configured mode. Render only newly obtained material. After authorization, check the account’s runtime_status separately before treating the connection as ready.
UnifyPort provides an unofficial interface. Its cancellation action is not a universal logout operation for the provider’s other sessions, nor does it remove upstream security controls.
FAQ
Does closing the QR dialog cancel authentication?
Not by itself. Closing the dialog changes your application UI; server-side cancellation requires the supported API action.
Should an expired QR automatically trigger cancel?
No. Expiry concerns the displayed login material. Read the current authorization state and follow the provider’s refresh flow unless the user actually intends to abandon the attempt.
Can I show cancellation success after a timeout?
No. Show an unconfirmed outcome and reconcile. Do not immediately start a new flow or repeatedly send cancellation.
Does cancellation stop billing or delete messages?
The cancellation contract establishes neither. Keep account retirement, billing, stored-message cleanup, and authentication controls separate.
Next step and sources
Implement the workflow against Cancel authentication. Test late polling responses, two tabs, approval racing with cancellation, a lost response, and an intentional restart. These are proposed tests, not reported results.
References checked on 2026-11-12:
Turn messaging integration into a stable product pipeline.
Start by sending through one API, then bring every inbound message back into your business system with standard events.