invalid_grant IMAP error: reconnect a Google or Microsoft mailbox
invalid_grant means the refresh token a tool uses to log in to your Google or Microsoft mailbox has expired or been revoked, so the IMAP login fails. Reconnect the mailbox through the tool's OAuth sign-in. If it keeps dropping, check password changes, revoked app access, admin policies and long idle periods.
Sohail Hussain9 min readShort answer
- invalid_grant means Google or Microsoft no longer accepts the saved OAuth refresh token for your mailbox. Retrying will not fix it.
- Reconnect the mailbox in your tool: sign in as the mailbox owner and approve every permission.
- If it drops again within days, look for a password change, an admin policy, repeated reconnects or a long idle period.
You open your sending tool and a mailbox shows as disconnected, or the log says "IMAP failure" with invalid_grant. The tool can no longer log in to the Google or Microsoft account on your behalf.
Why invalid_grant happens
OAuth lets a tool access your mailbox without storing your password. When you connect, the provider issues a refresh token. The tool exchanges it for short-lived access tokens each time it reads or sends mail. invalid_grant is the provider's way of saying that token, or the grant behind it, is no longer usable. It comes from Google's or Microsoft's authorization server, not from the tool or a recipient. Nothing you sent bounced. Sending and reply syncing for that one mailbox stop, and mail already sent is unaffected.
Microsoft describes the code as meaning some authentication material was invalid, unparseable, missing, or otherwise unusable, and its remedy is to get a new authorization code through a fresh sign-in. Google's guidance for the same error is similar: the token may have expired or been invalidated, so authenticate the user again and ask for consent to obtain new tokens.
The usual causes, roughly most common first:
- Password changed. Google lists a password change when the refresh token contains Gmail scopes as a reason tokens expire. Microsoft-side guidance also lists password changes, admin revocation and session resets as events that make refresh tokens invalid.
- Access revoked. The user revoked the app's access, or an admin or a cleanup process did.
- Too many live tokens. Google caps live refresh tokens per account and client. Once the limit is hit, creating a new token invalidates the oldest one without warning. Repeatedly reconnecting the same mailbox can kill an older connection.
- Long inactivity. On Google, a refresh token unused for six months expires. Microsoft has its own inactivity expiry, reported as AADSTS700082, a refresh token that expired due to inactivity.
- Admin policy. In Google Workspace, an admin who sets requested services to Restricted causes the
admin_policy_enforcederror. Microsoft 365 admins can do something similar with consent settings or Conditional Access. - Google app in Testing mode. This applies only if the tool uses an OAuth app you registered yourself. An external app with publishing status "Testing" is issued refresh tokens that expire in 7 days, with limited exceptions for basic profile scopes.
Google also documents session-length policies for Google Cloud organizations. These produce the same error after a set time, between 1 and 24 hours in the example it gives. That is rare for ordinary mailboxes, but worth knowing if the account sits inside a Cloud organization.
Step-by-step fixes
Fix 1: Reconnect the mailbox
- In your tool, open the email accounts list and find the mailbox marked disconnected.
- Choose the reconnect or re-authenticate action. If there is none, remove the account and add it again with the Google or Microsoft sign-in option.
- In the account chooser, pick the exact mailbox address. Do not accept whichever profile your browser happens to be signed in to.
- Approve every permission on the consent screen. A partial grant can look connected and then fail on the first sync or send.
- Send a test message and confirm that replies sync.
- Resume any campaigns that were paused or failed while the mailbox was down.
Use a private browser window if the wrong profile keeps getting selected.
Fix 2: Check whether access was revoked
Open your Google Account's security settings and look at the list of third-party apps with access. For Microsoft, open the app permissions page in your account's privacy settings. If the tool is missing, access was removed and a reconnect is the only way back. If it is present but the mailbox still fails, remove it from the list, then reconnect once to get a clean grant.
Fix 3: Stop issuing duplicate connections
If you reconnected the same mailbox several times in a row, or connected it to the same tool from several workspaces, an older token may have been pushed out by the limit. Reconnect once, leave it alone, and delete stale duplicate connections in the tool.
Fix 4: Ask your Workspace or Microsoft 365 admin
If several mailboxes on one domain broke at the same time, suspect policy rather than individual accounts. If the consent screen says an admin must approve the app, stop and send the admin the details below. In Google Admin, search for "API controls" to see whether third-party app access is restricted. In Microsoft 365, the admin should review user consent settings and any Conditional Access policy that applies.
Give the admin:
- the app name
- the time of the first failure
- the exact error text
- the list of affected mailboxes
Fix 5: Resolve a security event first
If Google or Microsoft emailed a security alert, or the account is locked or suspended, no tool can reconnect it. Resolve that with the provider, then reconnect.
Which cause do you have?
| Symptom | Likely cause | Fix |
|---|---|---|
| Broke right after a password change | Password reset invalidated the grant | Reconnect |
| Tool missing from the account's app access list | Access revoked | Reconnect |
| Mailbox idle for months | Inactivity expiry | Reconnect; keep it in use |
| Same mailbox reconnected many times | Token limit pushed out an old token | Remove duplicates, reconnect once |
| Many mailboxes on one domain at once | Admin policy or consent change | Ask the admin |
| Fails every 7 days on your own Google app | App in Testing status | Set the app to production |
| Provider security email received | Account flagged or locked | Resolve with the provider |
Do not keep retrying
A dead refresh token stays dead until a person signs in again. Repeated reconnect attempts can make things worse on Google by using up the per-account token limit.
Telling invalid_grant apart from other disconnects
Not every disconnected mailbox is an OAuth problem. Check the exact text:
invalid_grant: token problem; reconnect.- Authentication failed on a custom IMAP login: you are using a password, not OAuth. Check the password or app password.
- Connection timed out or refused: a network problem, or IMAP disabled on the account.
- A
535 5.7.8reply on sending: SMTP authentication failure. It can share the same root cause but needs its own check.
Our SMTP glossary entry and IMAP glossary entry cover the protocols, and the email header analyzer helps read a bounce.
Checklist before you try again
- You are signing in as the real mailbox owner.
- The tool is not still listed twice for the same mailbox.
- You approved every permission on the consent screen.
- No admin policy blocks the app (Workspace or 365).
- No provider security alert is open on the account.
- You will send a test message after reconnecting.
How to prevent a repeat
Connect each mailbox once, using the real owner's sign-in. Tell whoever manages passwords that a reset will disconnect connected tools, and plan a reconnect afterward. Remove mailboxes you no longer use instead of leaving them idle. In Workspace or 365, ask your admin to allow the app before you connect many mailboxes. Check connection status before launching a campaign, not after a quiet day with nothing sent.
Check before launch
Look at the connection status of every sending mailbox the day before a campaign starts. A token that died over the weekend is far cheaper to fix before sends are queued.
If nothing works
If reconnecting succeeds but the mailbox drops again within a day or two, with no password change, admin change or revoked access, contact your tool's support. If the consent screen is blocked or the account is locked, contact your Workspace or Microsoft 365 admin, or Google or Microsoft support. Include the mailbox address, timestamps of each failure, the exact error text, whether the account is personal or Workspace or 365, and what you already tried.
Subject: Mailbox keeps disconnecting with invalid_grant
Hi,
My mailbox {mailbox-address} ({Google Workspace / Microsoft 365 / personal}) shows as disconnected with the error "invalid_grant".
First failure: {date and time, timezone}
Reconnected: {date and time}; it failed again at {date and time}
Password changed recently: {yes/no}
Admin policy changes: {yes/no/unknown}
Steps tried: reconnected in a private window, approved all permissions, removed duplicate connections.
Can you check whether the token is being invalidated on your side or whether anything else is blocking the connection?
Thanks
What this means in Mailneo
Mailneo connects Gmail and Outlook mailboxes by OAuth, so the same provider-side rules apply to any mailbox you connect. You can test a connection from the email accounts area. I can't point to a documented reconnect prompt or a specific invalid_grant message in the app, so if a connected mailbox stops syncing, reconnect it with the provider's sign-in and run the connection test. Mailneo can't recover a suspended Google or Microsoft account or override an admin's policy; those stay with the provider or your admin.
Common questions
Does invalid_grant mean my emails were not delivered?
No. It is a login failure between the tool and the provider. Messages already sent are unaffected; only new sending and reply syncing for that mailbox stop until you reconnect.
Will I lose campaign data when I reconnect?
Reconnecting only replaces the saved authorization. Check your tool's documentation before removing and re-adding the account, because removal may behave differently from a reconnect.
Why does it keep coming back every week?
If it is a Google app you registered yourself, check whether it is in Testing status, since those refresh tokens expire after 7 days. Otherwise suspect repeated duplicate connections or a recurring admin or session policy.
Can I stop tokens from ever expiring?
No. Providers can invalidate a refresh token at any time, for example after a password change, revocation or inactivity. The practical approach is to catch disconnections early and reconnect.
For further reading, see Google's page on using OAuth 2.0 to access Google APIs and Microsoft's Entra authentication and authorization error codes.
Explore: Email Marketing Strategy
Related Articles
ActiveCampaign n8n error 301 on create contact: causes and fixes
A 301 from the ActiveCampaign node means the request went to a URL that redirects, so start with the API URL in your n8n credential. Copy it from Settings, then Developer, and check the scheme and path. Zapier 403 and cURL error 28 behind Cloudflare have different causes, covered below.
"Stage not on allowlist": Apollo to HubSpot sync fix
The error "Stage not on allowlist" means the contact's Apollo stage is not on the list of stages permitted to push to HubSpot. Open the HubSpot integration in Apollo, go to the Sync tab, and add that stage under "Stages for push contacts". Lifecycle stage mapping is a separate setting.
Salesmate "Authorization with Gmail failed": Gmail IMAP fix
Salesmate shows "Authorization with Gmail failed" when it can't read your Gmail account over IMAP. In Gmail settings, enable IMAP, choose "Do not limit the number of messages in an IMAP folder", and show All Mail in IMAP. Then reconnect the account in Salesmate. Other causes are covered below.
AWeber export "Stop Status" and "Stop Time" columns explained
In an AWeber subscriber export, a non-empty Stop Time and a non-zero Stop Status most likely mean the person has stopped receiving your mail, usually because they unsubscribed. AWeber doesn't explain the columns in the file, so verify against a few known unsubscribes, then import those rows as blocked, not subscribed.
Ready to supercharge your email marketing?
Start sending smarter emails with AI-powered campaigns. No credit card required.
Get Started Free