What Is Causing This Error?
The ‘401 error: invalid_client’ issue occurs if there is a mismatch between the Client ID on your Google Cloud account and the one you entered in your SMTP plugin.
Setting up your site to send emails using the Gmail API requires generating a Client ID from Google Cloud services. After generating the Client ID, you’ll need to add it to the settings page on your SMTP plugin.
If the Client ID you added is incorrect, you’ll likely experience this error.
Resolving the Error – Solution
To resolve the ‘401 error: invalid_client’ issue, you’ll need to make sure the Client ID value on your SMTP plugin matches the one on Google Cloud.
We recommend copying the value from Google Cloud and adding it to the appropriate field in your SMTP plugin.
To find your Client ID, log in to Google Cloud Console. After that, go to APIs & Services » Credentials.
In the OAuth 2.0 Client IDs section, click the copy icon next to the Client ID to copy its value.
Once you’ve copied the Client ID, return to your SMTP plugin and paste it into the Client ID field. Be sure to save your changes afterward.
Some SMTP plugins require an extra step of authorizing the plugin to send emails using your Google account.
For example, if you use WP Mail SMTP, you’ll need to click the Allow plugin to send emails using your Google account button after saving your changes.
On the authentication page, you’ll need to select the Google account that’s linked to your Google Cloud app.
That’s it! Now you know the causes of the ‘401 error: invalid_client’ issue and how to resolve it.
If you’d like to learn how to troubleshoot other common errors, check out the following tutorials: