### [Error: invalid_grant: Bad Request](https://wpmailsmtp.com/docs/error-invalid_grant-bad-request/)

**Published:** May 17, 2026
**Author:** David Ozokoye

**Content:**

**Note**: This guide applies to the [Gmail mailer](https://wpmailsmtp.com/docs/how-to-set-up-the-gmail-mailer-in-wp-mail-smtp/ "Gmail") in WP Mail SMTP.

## What This Error Means

The OAuth credentials (Client ID and Client Secret) stored in WP Mail SMTP are misconfigured or don’t match the Google Cloud Console application. Unlike the “token expired” variant, this is a configuration mismatch, not just a stale token.

## Common Causes

- Client ID or Client Secret typo when entering in WP Mail SMTP
- Wrong OAuth client type used (e.g. **Desktop app** instead of **Web application**)
- Authorized redirect URI in Google Cloud Console doesn’t include the WP Mail SMTP callback URL
- OAuth credentials in Google Cloud Console no longer exist (deleted or replaced with new ones)

## How to Fix

Here is the complete step-by-step guide to resolving the error.

### Step 1: Verify the OAuth Client Type

The most common cause is an OAuth credential created with the wrong application type. Start by checking what you have.

Open the [Google Cloud Console](https://console.cloud.google.com/ "Google Cloud Console") and select the project used for WP Mail SMTP. Then, navigate to **APIs & Services » Credentials**.

Under **OAuth 2.0 Client IDs**, find your credential and confirm the type is **Web application**. If it already says **Web application**, skip to Step 2. If the type is **Desktop app** or anything else, create a new credential.

To create a new one, click **Create credentials** and select **OAuth client ID**. Then, set **Application type** to **Web application**.

![Select Web application as the application type](https://wpmailsmtp.com/wp-content/uploads/2021/10/select-web-application.png)Under **Authorized redirect URIs**, click **+ ADD URI** and enter `https://connect.wpmailsmtp.com/google/`.

![Enter the redirect URI](https://wpmailsmtp.com/wp-content/uploads/2021/10/input-for-uri.png)Finally, click **Create**.

![Click create to continue](https://wpmailsmtp.com/wp-content/uploads/2025/12/click-create.png)### Step 2: Verify the Redirect URI

If your OAuth client already had the correct type, the next thing to check is the redirect URI.

In **APIs & Services » Credentials**, click the pencil icon next to your **Web application** OAuth client. Then, under **Authorized redirect URIs**, confirm `https://connect.wpmailsmtp.com/google/` is listed exactly, including `https` and the trailing slash.

If the URI is missing, click **+ ADD URI**, paste the URL above, and click **Save**.

### Step 3: Copy the Client ID and Client Secret

With the OAuth client type and redirect URI confirmed, copy the credentials so you can paste them into WP Mail SMTP.

In **APIs & Services » Credentials**, under **OAuth 2.0 Client IDs**, click the pencil icon next to your credential.

![Edit client ID](https://wpmailsmtp.com/wp-content/uploads/2021/10/click-pencil-icon.png)Then, copy the **Client ID**.

![Copy the Client ID](https://wpmailsmtp.com/wp-content/uploads/2025/12/copy-client-id.png)Next, click **+ Add secret** to generate a new client secret.

![Click Add secret to generate a Client Secret](https://wpmailsmtp.com/wp-content/uploads/2025/12/add-secret.png)Finally, copy the **Client Secret**.

**Note**: Be careful not to copy any extra text or spaces with your Client ID or Client Secret. Google only shows the full Client Secret once.

### Step 4: Update WP Mail SMTP and Re-Authorize

Now paste the new credentials into WP Mail SMTP and reconnect your Google account.

Start by going to **WP Mail SMTP » Settings** and scrolling to the **Google / Gmail** section. Then, click **Remove Connection** to clear the old credentials.

![Click Remove Connection](https://wpmailsmtp.com/wp-content/uploads/2020/10/Remove-Connection-in-WP-Mail-SMTP.png)After that, paste the new **Client ID** and **Client Secret** into the corresponding fields.

![Paste the Client ID and Client Secret](https://wpmailsmtp.com/wp-content/uploads/2022/11/enter-new-client-secret.png)Next, click **Save Settings**, then click **Allow plugin to send emails using your Google account** to start the OAuth flow.

![Click Allow plugin to send emails using your Google account](https://wpmailsmtp.com/wp-content/uploads/2022/12/allow-google-to-send-emails.png)Finally, select your Google account and grant the requested permissions.

### Step 5: Send a Test Email

Confirm the fix by sending a test email.

To test the fix, go to **WP Mail SMTP » Tools** and click the **Email Test** tab. Enter a recipient address in the **Send To** field, leave the **HTML** toggle ON, and click **Send Email**.

![Test email tab](https://wpmailsmtp.com/wp-content/uploads/2024/10/test-email-tab-1024x1002.png)Once done, check for a success message and confirm the email arrived in your inbox.

## Notes

- The redirect URI must match exactly, including `https` vs `http` and trailing slashes.
- If the Gmail API isn’t enabled, go to **APIs & Services » Library**, search for “Gmail API”, and click **ENABLE**.
- If the error recurs every 7 days after fixing credentials, the Google Cloud project may be in “Testing” mode. Publish the app to production in **APIs & Services » OAuth consent screen » Audience** and click **PUBLISH APP**.

That’s It! You now know how to fix the ‘invalid\_grant: Bad Request’ error in Gmail and get your emails sending again through WP Mail SMTP.

**Categories:** Gmail Errors, Error Library

---

