Google Cloud

How to Create an OAuth Client ID and Client Secret in Google Cloud Console

By Rizwana Abdul Salam · SEO & WordPress Consultant  |  Updated: November 25, 2026 · 7 min read

Key takeaways

  • An OAuth Client ID and Secret are the credentials Google issues so your app (like a WordPress SMTP plugin) can send email, or access other Google APIs, on your behalf.
  • You create them inside a free Google Cloud project — no paid plan required for this.
  • While your app is in “Testing” status, only the Google accounts you add as Test Users can authenticate with it.
  • The Authorized Redirect URI must match exactly, character for character, or you’ll get a redirect_uri_mismatch error.
Part 01

What Is an OAuth Client ID and Secret?

An OAuth Client ID and Client Secret are the two pieces of identification Google issues to an application so it can securely act on your behalf with a Google service — like sending email through Gmail’s SMTP servers, or reading a Google Calendar. Think of the Client ID as your app’s username with Google, and the Client Secret as its password. Together, they let Google’s servers verify that a request really is coming from your website, not an impersonator.

This guide walks through creating these credentials on their own, generically. If you’re setting them up specifically to fix a WordPress contact form that isn’t delivering email, see our full walkthrough: Why Your WordPress Contact Form Isn’t Sending Emails (And How We Fixed It for Free).

Part 02

Before You Start

You’ll need a Google account, about 5–10 minutes, and the exact callback URL your application will use to complete the OAuth login (its “redirect URI”). If you’re setting this up for a WordPress SMTP plugin like SureMail or WP Mail SMTP, that URL is shown directly on the plugin’s own connection settings screen — copy it before you start, since you’ll need it later.

Google Cloud now also requires 2-Step Verification to be enabled on your Google account before it will let you access the Console at all, so turn that on first at myaccount.google.com/security if you haven’t already.

Part 03

Step 1: Create or Select a Google Cloud Project

Open console.cloud.google.com and sign in. If you don’t already have a project, click the project dropdown at the top of the page and choose New Project. Give it a name — something like “My Website SMTP” works fine — and click Create. If you already have a project you’d rather use, just select it from the dropdown instead; one project can hold several sets of credentials.

Part 04

Step 2: Enable the API You Need

In the left sidebar, open APIs & Services → Library and search for the specific API your app needs. For sending email through a Gmail account, search for Gmail API and click Enable. If you’re building something else, enable only the API that matches what you actually need — there’s no reason to enable more than that.

Part 05

Before Google lets you create a Client ID, it requires an OAuth consent screen — the screen people see when they grant your app access. Open APIs & Services → OAuth consent screen (sometimes labelled “Google Auth Platform → Branding”). Choose External as the user type unless this is an internal tool on a Google Workspace account. Fill in an app name, a support email, and a contact email, then agree to the API Services User Data Policy.

Part 06

Step 4: Add Test Users

While your app’s publishing status is “Testing” — the default, and perfectly fine for a single website’s own use — only accounts you explicitly add as test users can sign in and authorise it. Open the Audience section and add the Google account(s) you plan to authenticate with, typically the same mailbox you intend to send email from. Skipping this step is the single most common reason people get stuck staring at a blank or blocked sign-in screen.

Part 07

Step 5: Create Your OAuth Client ID

Open Clients (sometimes labelled “Credentials”) and click Create Client. Choose Web application as the application type and give it a descriptive name, like “WordPress SMTP.”

Part 08

Step 6: Set the Correct Redirect URI

Under Authorized redirect URIs, click Add URI and paste the exact callback URL your application gave you. This has to match character for character — including https:// and any trailing slash — or Google will reject the login with a redirect_uri_mismatch error. Click Create once it’s in place.

Part 09

Step 7: Copy and Store Your Credentials

Google immediately shows you the Client ID and Client Secret in a popup — and this is the only time the full Client Secret is ever displayed. Copy both values now and store them somewhere secure, like a password manager. If you close this dialog without copying the secret, you’ll have to come back and generate a new one.

Google Cloud OAuth client created screen showing where the Client ID and Client Secret appear, sensitive values redacted
Google shows your new Client ID the moment the OAuth client is created (value redacted here).
Google Cloud OAuth client created dialog showing where the Client Secret appears, value redacted
The Client Secret is shown only once, in the same dialog, directly below the Client ID.
Part 10

Common Errors and How to Fix Them

Error 401: invalid_client — almost always means the Client ID pasted into your app is incomplete or doesn’t match Google Cloud Console. A full Client ID always ends in .apps.googleusercontent.com and starts with a long numeric project prefix; check that nothing got truncated when you copied it.

redirect_uri_mismatch — the URI registered in Google Cloud Console doesn’t exactly match what your app sent. Compare them character by character, including http vs. https.

“Access blocked: this app hasn’t completed verification” — your account isn’t on the Test Users list yet. Add it under Audience and try again.

Part 11

Keeping Your Credentials Secure

Treat a Client Secret exactly like a password: never paste it into a chat, a public code repository, or a screenshot you plan to share. If a secret is ever exposed, go back to Clients in Google Cloud Console and reset it immediately — the old one stops working the moment you do. Only enable the specific API scopes your application actually needs, and remove test users you no longer recognise.

Part 12

Final Thoughts

If you were doing this to fix email delivery on your own WordPress site, head back to Why Your WordPress Contact Form Isn’t Sending Emails to finish connecting these credentials to SureMail.

Frequently Asked Questions

Is creating a Google Cloud OAuth Client ID free?

Yes. Creating a project, enabling an API, and issuing OAuth credentials for your own use costs nothing. Google Cloud’s paid tiers only come into play at a scale far beyond a single website’s email or calendar integration.

Why do I need to add myself as a “test user”?

Any app that hasn’t gone through Google’s formal verification process starts in “Testing” status, which restricts sign-in to a short list of approved accounts. For a personal or single-business integration, staying in Testing and adding yourself as a test user is normal and sufficient — full verification is only needed for a public app used by the general public.

What do I do if I lose my Client Secret?

You can’t retrieve it again — Google only displays it once. Go back to Clients in Google Cloud Console, open that OAuth client, and generate a new secret. Update it wherever the old one was used.

Can I use the same Client ID for more than one website?

Not reliably. Each OAuth client is tied to a specific set of Authorized redirect URIs, so a separate client per site keeps things cleanly scoped and easier to revoke individually if one site is ever compromised.

About Rizwana Abdul Salam

Rizwana Abdul Salam is an SEO consultant and the founder of Riz Digital Marketing, based in North Kerala. She holds a B.Tech in Computer Science and Engineering from CUSAT and specialises in technical SEO, local SEO, and AI search optimisation for businesses across Kerala, the GCC, and the USA.

Setting this up to fix email delivery? Read Why Your WordPress Contact Form Isn’t Sending Emails, or see more guides on the blog.

Leave a Comment

Your email address will not be published. Required fields are marked *