← Back to the journal

Why WeChat Official Account Logins Expire Every 3–4 Days

Three measured rounds show the WeChat Official Account (mp.weixin.qq.com) QR login dies after 3–4 days no matter how active the session is. Here is what still works: expiry alerts, a retry queue and a pre-flight login check.

If you automate a WeChat Official Account (the publishing backend at mp.weixin.qq.com that Chinese brands and creators use like a newsletter + blog), expect the QR-code login to die roughly every 3–4 days. It behaves like a fixed lifetime counted from the moment you scan: keep-alive pings, periodic checks and real daily activity do not extend it. Stop trying to keep the session alive; plan around its expiry instead.

Below are our measurements, why heartbeats don't help, and the three mechanisms we ended up building into OmniGoAI's OmniPost.

The measurements

We keep a dozen platform logins open on one machine and check every 10 minutes whether each is still valid. Three WeChat rounds:

  1. Logged in Aug 26, 09:29 → expired by Aug 30.
  2. Logged in Sep 2, 14:37 → expired before the morning of Sep 6.
  3. Logged in Oct 14, 22:28 → still creating drafts on Oct 16, expired by Oct 20.

In the first two rounds the account created a real draft every day. After round two expired, nobody noticed, and five days of scheduled jobs failed at the very last step: ten wasted runs across two accounts.

For comparison, on the same machine with the same checks, Juejin and Bilibili (two Chinese developer/video sites) were still logged in after 41 days, and 11 other platforms were all still valid 7.5 days after re-login. Those are lower bounds; none had expired as of Oct 22.

Why heartbeats don't help

Many sites log you out after a period of inactivity, so periodic refreshes work. WeChat's backend didn't care how active we were: the session ended on schedule. That is our inference from behavior, not a documented policy, and the exact lifetime may vary by account type. The practical conclusion holds: nothing on the client side extends it.

1. Warn before it expires

Turn expiry into something predictable:

  • Record the time of each successful login.
  • Predict expiry from an observed lifetime (use 3 days for WeChat to stay safe). If a key cookie carries its own expiry date, prefer that. When several signals exist, take the earliest.
  • Notify once when you enter the last 12 hours, at most once per login cycle.

One easy bug: don't update the login time when a validity check succeeds. If you do, the start point keeps moving forward and the warning never fires.

2. Queue failed posts for retry

When a publish fails with "login required", don't just mark it failed:

  1. Snapshot the content you were about to publish.
  2. Put it in a retry queue with a cooldown (e.g. 10 minutes) and a window (e.g. 48 hours).
  3. Release the queue as soon as a re-login is detected.
  4. Allow one entry per title and target, and clear the snapshot after it completes.

Don't queue jobs that also hit a hard error (re-login won't fix a content rejection), and deduplicate before retrying. A missed post is better than a duplicate one.

3. Check the login before the job starts

Make "is the account logged in?" the first step of every scheduled job, not something you discover after the agent has written and illustrated the post. Our five wasted days happened because the job didn't check first.

A trap: self-learned lifetimes get polluted

We once let the app learn each platform's session lifetime from observed expiries. It "learned" 21.5 hours for WeChat and 804 hours for CSDN. The cause: right after startup, the browser partition hadn't finished loading cookies from disk, so the first check went out without them, the site replied "not logged in", and the app recorded time-since-login as the lifetime. The fix: discard observations under 24 hours, and confirm the request actually carried the login cookie before declaring a session dead.

FAQ

Can I avoid scanning QR codes altogether?

Yes, through the official developer API: exchange AppID and AppSecret for an access token that your code can refresh automatically. You'll need to whitelist your server IP, and the available endpoints depend on account type and verification status. See our guide to creating drafts via the WeChat API.

Do multiple accounts expire faster?

We saw no evidence of that. What matters is giving each account its own browser partition so cookies don't overwrite each other; see multi-account session isolation.

Can the QR scan be automated?

We don't recommend it. The scan is the platform's way of confirming a human is present; working around it is fighting their risk controls and puts the account at far greater risk than scanning every few days.

How OmniPost handles it

OmniPost ships all three mechanisms: a notification 12 hours before a login expires, automatic retry of posts that failed because of an expired login (released the moment you log back in), and a single alerts check (omnipost alerts, or the MCP tool list_alerts) that an agent can run before each day's distribution. You still have to scan WeChat every few days, but you won't lose five days without knowing. If you drive multi-platform publishing from Claude Code or another agent, you can download OmniPost.

#WeChat#sessions#automation#ops

More from the journal