Fixing the Google OAuth redirect_uri_mismatch Error in WP Mail SMTP
Content
If you're using the WP Mail SMTP plugin to send emails through Gmail, you may have encountered a frustrating error that stops the connection process: Error 400: redirect_uri_mismatch. This is a common issue that stems from Google's security protocols, not from the plugin itself. This guide will explain why it happens and walk you through the most effective solutions.
What Causes the redirect_uri_mismatch Error?
This error is a security restriction from Google. It occurs when the 'Authorized Redirect URI' registered in your Google Cloud Console project does not exactly match the URI that the 'WP Mail SMTP by WPForms' plugin uses during the OAuth authentication process. The required URI is:
https://connect.wpmailsmtp.com/google/
Any discrepancy, such as a missing trailing slash or a typo, will trigger this error. Google's recent interface updates can also sometimes make the correct field difficult to find.
How to Resolve the redirect_uri_mismatch Error
1. Verify the Authorized Redirect URI
The most common fix is to double-check the URI in your Google Cloud Console.
- Log into your Google Cloud Console.
- Select your project.
- Navigate to APIs & Services > Credentials.
- Click on the name of your OAuth 2.0 Client ID credentials.
- In the Authorized redirect URIs section, ensure the following line is present exactly as shown:
https://connect.wpmailsmtp.com/google/ - Important: The Authorized JavaScript origins section should be left empty. Placing the URI here is a common mistake and will cause the error.
- Click Save.
2. Publish Your OAuth Consent Screen
If your app is in "Testing" mode, only specific user accounts can authenticate with it. To make it available, you need to publish it.
- In your Google Cloud Console, go to APIs & Services > OAuth consent screen.
- If the publishing status is "Testing", click PUBLISH APP.
- Confirm the action. This changes the status to "In production".
3. Clear Browser and Google Sessions
Sometimes, a stuck browser session can interfere with the authentication flow.
- Completely sign out of all Google accounts in your browser.
- Clear your browser cache and cookies.
- Sign back in only to the specific Google account that owns the Cloud Console project.
- Return to your WordPress site and try the connection again.
4. Follow an Updated Guide
Google's console interface changes over time. If the fields look different than you expect, following a recent, visual guide can be incredibly helpful. The 'WP Mail SMTP by WPForms' team provides a detailed documentation guide with screenshots that reflects the current process.
What If the Error Persists?
If you've checked all the steps above and are still encountering the error, consider these additional troubleshooting steps:
- Check for Conflicts: Temporarily disable other plugins and switch to a default WordPress theme (like Twenty Twenty-Four) to rule out a conflict.
- Review Debug Logs: In your WordPress admin, go to WP Mail SMTP > Tools > Debug Events. This may provide a more detailed error message.
- Ensure Correct Account: When prompted by Google to authenticate, make sure you are logging into the same account that you used to create the Cloud Console project and credentials.
By methodically working through these steps, you can resolve the redirect_uri_mismatch error and re-establish a secure connection between your website and Gmail.
Related Support Threads Support
-
Google blocking accesshttps://wordpress.org/support/topic/google-blocking-access-2/
-
Gmail Authentication Errorhttps://wordpress.org/support/topic/gmail-authentication-error/
-
CLIENT SECRET # MISSING/INCORRECThttps://wordpress.org/support/topic/client-secret-missing-incorrect/
-
“Invalid Origin: URIs must not contain a path or end with “/”.https://wordpress.org/support/topic/invalid-origin-uris-must-not-contain-a-path-or-end-with/
-
Authorization Errorhttps://wordpress.org/support/topic/authorization-error-17/
-
Error executing “ListEmailIdentities”https://wordpress.org/support/topic/error-executing-listemailidentities/
-
Connection to Gmail broken – Error 400: redirect_uri_mismatchhttps://wordpress.org/support/topic/connection-to-gmail-broken-error-400-redirect_uri_mismatch-2/
-
authentication error although provide client id and secret id properlyhttps://wordpress.org/support/topic/authentication-error-although-provide-client-id-and-secret-id-properly/
-
exclude google recaptchahttps://wordpress.org/support/topic/exclude-google-recaptcha/
-
How to Get AJScript and AUTH redirect URIshttps://wordpress.org/support/topic/how-to-get-ajscript-and-auth-redirect-uris/
-
Can’t Remove Oath Consenthttps://wordpress.org/support/topic/cant-remove-oath-consent/
-
GMail stopped workinghttps://wordpress.org/support/topic/gmail-stopped-working/
-
Invalid Granthttps://wordpress.org/support/topic/invalid-grant-3/
-
GMail OAuth consent screen differs from documentationhttps://wordpress.org/support/topic/gmail-oauth-consent-screen-differs-from-documentation/
-
cURL error 2https://wordpress.org/support/topic/curl-error-2-2/
-
Cannot Send Test Email after setup with Gmail APIhttps://wordpress.org/support/topic/cannot-send-test-email-after-setup-with-gmail-api/
-
(HELP) Google hasn’t verified this apphttps://wordpress.org/support/topic/help-google-hasnt-verified-this-app/
-
Google OAuth 2.0 Policy Issuehttps://wordpress.org/support/topic/google-oauth-2-0-policy-issue/
-
Google – No API redirect URI anywhere!https://wordpress.org/support/topic/google-no-api-redirect-uri-anywhere/
-
Redirect URI invalid originhttps://wordpress.org/support/topic/redirect-uri-invalid-origin/
-
invalid redirect must end with a public top-level domainhttps://wordpress.org/support/topic/invalid-redirect-must-end-with-a-public-top-level-domain/
-
No longer workinghttps://wordpress.org/support/topic/no-longer-working-153/
-
Gmail not authorizinghttps://wordpress.org/support/topic/gmail-not-authorizing/
-
Google Verification Errorhttps://wordpress.org/support/topic/google-verification-error-2/
-
Connection to Gmailhttps://wordpress.org/support/topic/connection-to-gmail/
-
Connection to Gmail broken – Error 400: redirect_uri_mismatchhttps://wordpress.org/support/topic/connection-to-gmail-broken-error-400-redirect_uri_mismatch/