MailDesk docs
Advanced technical reference

Fix Gmail synchronization setup errors

4 min read Odoo 18.0

This is an advanced reference for administrators. Most setups do not need it. The everyday page is Enable faster Gmail synchronization.

When the Gmail setup assistant cannot enable push, it stops at the first failing step and shows a code, an explanation and a suggested fix. This page lists each Gmail code.

Who this is for: MailDesk and Google Cloud administrators.

You need: MailDesk Pro and the Mailbox administrator group.

Mail does not stop

These errors only block push registration. Scheduled sync keeps delivering Gmail mail about every 2 minutes. Running validation again is always safe.

Quick reference

Code Fix in Command
AUDIENCE_MISMATCH MailDesk Run the assistant again
SIGNER_BAD_FORMAT Google Cloud gcloud iam service-accounts list
WATCH_403_TOPIC_IAM_MISSING Google Cloud gcloud pubsub topics add-iam-policy-binding maildesk-gmail-push --member='serviceAccount:[email protected]' --role='roles/pubsub.publisher'
WATCH_403_GMAIL_API_NOT_ENABLED Google Cloud gcloud services enable gmail.googleapis.com pubsub.googleapis.com
WATCH_400_BAD_TOPIC Google Cloud gcloud pubsub topics describe maildesk-gmail-push --format='value(name)'
WATCH_400_TOPIC_PROJECT_MISMATCH Google Cloud gcloud config set project <oauth-client-project>
WATCH_404_TOPIC_NOT_FOUND Google Cloud gcloud pubsub topics list --format='value(name)'
WATCH_400_OAUTH_SCOPE_MISSING MailDesk Reconnect the mailbox
WATCH_401_OAUTH_INVALID MailDesk Reconnect the mailbox

If you changed the default topic name, use your name instead of maildesk-gmail-push.

The most common mistake: project mismatch

Gmail requires the Pub/Sub topic to be in the same Google Cloud project as the OAuth client your mailbox signed in with. If it is in another project, Gmail refuses the watch even when the topic and permissions are correct.

Before you start, find the project that owns the OAuth client and run the setup script with PROJECT_ID set to that project. The error WATCH_400_TOPIC_PROJECT_MISMATCH names the project Gmail expects.

Webhook and audience errors

These come from MailDesk's own checks, before Gmail is contacted. The webhook address codes (WEBHOOK_URL_UNSET, WEBHOOK_URL_NOT_HTTPS, WEBHOOK_UNREACHABLE_DNS, WEBHOOK_UNREACHABLE_TIMEOUT, WEBHOOK_UNREACHABLE_TLS, WEBHOOK_UNEXPECTED_STATUS) are explained in Set up HTTPS for faster synchronization.

AUDIENCE_MISMATCH: the OIDC audience does not match the webhook URL

  • Meaning: Pub/Sub signs each push with a token whose aud claim must equal the URL it is sent to. The saved audience differs from the webhook address.
  • Fix: Run the assistant again so MailDesk saves both as <web.base.url>/maildesk/push/gmail. In Google Cloud, update the push subscription's audience to match.
  • Google reference: Authenticate push subscriptions

Signer errors

SIGNER_BAD_FORMAT: the signer email is malformed

  • Meaning: The email must look like <name>@<project-id>.iam.gserviceaccount.com, in lowercase.
  • Fix: Copy the full email without a display name or spaces: gcloud iam service-accounts list
  • Google reference: Service account overview

Errors from Gmail users.watch

These appear when you click Enable Realtime.

WATCH_403_TOPIC_IAM_MISSING: Gmail cannot publish to your topic

WATCH_403_GMAIL_API_NOT_ENABLED: the Gmail API is off in your project

  • Meaning: The Gmail API has never been used or was disabled.
  • Fix: Enable it, then try again after 30 to 60 seconds.
  • Google reference: Enabling and disabling services

WATCH_400_BAD_TOPIC: the topic name is malformed

  • Meaning: Gmail rejected the topic name. It must be projects/<project-id>/topics/<topic-name>.
  • Fix: Read the full name with the command in the quick reference and paste it into the assistant.
  • Google reference: Create a push subscription

WATCH_400_TOPIC_PROJECT_MISMATCH: the topic is in the wrong project

  • Meaning: The topic is not in the OAuth client's project. The detail line names the expected project.
  • Fix: Run the setup script with PROJECT_ID set to that project, then paste the new topic name. Switch the active project first with gcloud config set project <oauth-client-project>.
  • Google reference: Create a push subscription

WATCH_404_TOPIC_NOT_FOUND: the topic does not exist

  • Meaning: The name in the assistant matches no topic in your project. It was deleted or mistyped.
  • Fix: List your topics, then recreate the missing one with the script or paste the correct name.
  • Google reference: Create a push subscription

OAuth and scope errors

These are fixed in MailDesk, not in Google Cloud.

WATCH_400_OAUTH_SCOPE_MISSING: the scope does not cover users.watch

  • Meaning: The stored token was issued without gmail.modify (or gmail.readonly plus gmail.metadata).
  • Fix: Disconnect and reconnect the mailbox, and accept all requested permissions. Use Verify token now to check the token and Reconnect Gmail to sign in again (both are on the mail server form). Then click Enable Realtime again.
  • Google reference: Gmail API OAuth scopes

WATCH_401_OAUTH_INVALID: the credentials are invalid or expired

  • Meaning: Google no longer accepts the stored token. The user revoked access, the client secret changed, or the token expired.
  • Fix: Reconnect the mailbox, accept the permissions, then run validation again.
  • Google reference: Gmail API OAuth scopes

A code that is not listed

The assistant can show WATCH_UNKNOWN_<status> when Google's answer has a shape MailDesk does not know, often a temporary 5xx error.

  1. Try once more after about 30 seconds.
  2. If it repeats, find the response in the Odoo server log (MailDesk keeps at most 500 characters of it).
  3. Contact support with the code and that text. Do not include tokens or secrets.

Next step

Fix missing or delayed emails