Coding

How to Create a Google OAuth Client ID (Step by Step)

To create a Google OAuth client ID, open the Google Cloud Console, go to Menu > Google Auth platform > Clients, click Create Client, choose an application type and click Create. Google then lists the new client under OAuth 2.0 Client IDs, and the client ID is the value ending in .apps.googleusercontent.com.

The console has been reorganised under the name "Google Auth platform", so older tutorials that mention "APIs & Services > Credentials" may not match what you see. The steps below follow Google's current documentation as of November 2026. If you want the theory first, see OAuth explained.

Before you start

  • A Google Cloud project. The Clients page asks you to select or create one if you have none selected.
  • A registered application. Google's help page says that if you have not set up your app yet, the console prompts you to register it before you can create a client. That registration is the name, support email and audience settings of your consent screen.
  • The Google APIs you plan to call must be enabled in the API Console. Google's web server guide says any application that calls Google APIs needs to enable them first.

Create the client ID

  1. In the Google Cloud Console, open Menu > Google Auth platform > Clients. The direct address is console.developers.google.com/auth/clients.
  2. Click Create Client.
  3. Under Application type, choose the type that matches your app (see the table below).
  4. Enter a Name. It is shown only in the Google Cloud Console, not to your users.
  5. Fill in the fields that the chosen type asks for.
  6. Click Create.

Google also shows an optional checkbox, Use this client for an AI-powered agent, for apps that take actions on behalf of users. It cannot be changed after the client is created, and Google says to create separate clients if one app has both agent and standard user features. Leave it off for an ordinary app.

Which application type to choose

Application typeWhat you enter
Web application (server-side)One or more Authorized redirect URIs, the endpoint on your server that receives the OAuth response.
Web application (client-side JavaScript)One or more Authorized JavaScript origins, the browser origin of your page.
AndroidThe package name from AndroidManifest.xml and the SHA-1 certificate fingerprint of your signing certificate.
iOSThe Bundle ID from Info.plist. App Store ID and Team ID (10 characters) are optional.
Chrome ExtensionThe 32-character item ID from the Chrome Web Store URL or Developer Dashboard.
Desktop appNothing beyond the name.
TVs and Limited Input devicesNothing beyond the name.

For a typical website with a back end, pick Web application and add your redirect URI. Click Add URI under the matching heading for each value. Google recommends one client ID per platform, so a product with a website and an Android app ends up with two clients, not one shared client.

Where to find the client ID and client secret

Open the Clients page and click the client's name. The client ID looks like the placeholder Google uses in its own samples:

123456789.apps.googleusercontent.com

That value is an example, not a real client. Real IDs are longer, but they always end with .apps.googleusercontent.com.

The client ID is a public identifier. It appears in the authorization URL that your user's browser opens, so it does not need to be hidden. The client secret is different. Google's help page says public clients (native and JavaScript apps) do not use secrets, while private clients such as server apps do. It also says the secret is "only visible and downloadable from the Google Cloud Console at the time of their creation". Afterwards the console shows only the last four characters, so copy the full value into a secret manager at once. Google's web server guide gives the same warning for the downloaded client_secret.json file: do not keep it in a publicly accessible location.

Keep the secret out of your repository, your front-end bundle and your logs. Load it from an environment variable or a secret store at runtime. If it leaks, treat it like any other credential, as described in what to do when an API key leaks: create a new secret, deploy it, and disable the old one.

Use the client ID in an authorization request

The client ID goes into the request that starts the sign-in. For a web server application, the authorization endpoint is https://accounts.google.com/o/oauth2/v2/auth, which Google says is accessible only over HTTPS. Four parameters are required:

  • client_id: your client ID.
  • redirect_uri: where Google sends the user afterwards. It "must exactly match one of the authorized redirect URIs" configured for the client.
  • response_type: code for web server applications.
  • scope: a space-delimited list of the scopes you are requesting.

An example URL, with placeholder values, split over lines for readability:

https://accounts.google.com/o/oauth2/v2/auth
  ?client_id=123456789.apps.googleusercontent.com
  &redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback
  &response_type=code
  &scope=openid%20email

Most people never build this by hand. Google's client libraries and general OAuth libraries take the client ID, secret and redirect URI as configuration and generate the request for you. Use one, and let it handle state and PKCE as well.

Redirect URI rules

Google's help page lists what a redirect URI may and may not contain:

  • It must use HTTPS, except for localhost.
  • It cannot use a raw IP address, except localhost IPs.
  • It cannot contain wildcards, fragments, userinfo, path traversal or open redirects.
  • The host's top-level domain must be on the public suffix list.

Authorized JavaScript origins follow similar rules. For development, add your localhost address as a second URI on the same client or, better, use a separate client for development so that production settings stay clean.

Testing mode, publishing and verification

Creating the client does not mean every Google user can sign in. Your app's audience and publishing status decide that.

  • External apps are available to any user with a Google Account. Internal is available to projects tied to a Google Cloud organization and limits authorization to members of that organization. Users outside it get an org_internal error.
  • In Testing, access is limited to up to 100 test users listed on the consent screen. Per Google, test-user authorizations last seven days from consent, and a refresh token issued in that state also expires after seven days. The exception is apps that request only the openid, userinfo.email and userinfo.profile scopes (or their OpenID Connect equivalents).
  • In In production, any user with a Google Account can authorize the app. You get there with the Publish app button.
  • Requests for sensitive or restricted scopes need OAuth verification. Without it, users see an unverified app warning, and Google applies a lifetime cap of 100 new users after the unverified app screen is shown. That cap cannot be reset.

So an app that works for you but fails for everyone else is usually still in Testing, or is asking for a scope that needs verification.

Common errors

redirect_uri_mismatch

The redirect_uri in your request does not match an authorized redirect URI on the client. Google's guide says the scheme (http or https), the case and the trailing slash must all match. https://app.example.com/callback and https://app.example.com/callback/ are different values. Edit the client on the Clients page and compare the strings character by character.

origin_mismatch

The same problem for JavaScript origins: the page making the request is served from an origin that is not on the client's authorized list.

Changes do not take effect straight away

Google's help page says changes to redirect URIs and origins can take from 5 minutes to a few hours to apply. If you have just saved a correct value and still get a mismatch, wait before changing anything else.

If sign-in still fails

Check, in this order: the client type matches the platform (a Web client used from an Android app will not work); the redirect URI in the request is the exact string saved on the client; the app is published, or your account is on the test user list; and the APIs you call are enabled in the project. For the broader picture of how tokens and scopes fit together, read OAuth explained.

Frequently asked questions

Is a Google OAuth client ID secret?
No. The client ID is a public identifier that appears in the authorization URL in the browser. The client secret is the confidential part, and only server-side (web application) clients use one. Public clients such as native and JavaScript apps do not use secrets.
Can I view the client secret again after creating it?
Google's help page says the secret is only visible and downloadable from the Google Cloud Console at the time of creation. Afterwards the console shows only its last four characters. Store the full value in a secret manager straight away, and create a new secret if you lose it.
Why does my app say redirect_uri_mismatch?
The redirect_uri in your authorization request does not exactly match any authorized redirect URI on the OAuth client. The scheme, case and trailing slash must all match. Fix it by editing the client on the Clients page, then allow some time for the change to apply.
Do I need a separate client ID for each platform?
Yes. Google's documentation says to create a separate client ID for each platform your app runs on, for example one for your web application, one for Android and one for iOS.

Sources