How to Create a Google Drive OAuth Client ID
In this article
To create an OAuth client ID for Google Drive, you need a Google Cloud project, the Google Drive API enabled, and an OAuth consent screen configured. Then go to Credentials, click Create Credentials, choose OAuth client ID, pick your application type, and copy the client ID and secret. This guide walks through each step using the current Google Cloud Console, with notes on what changes between desktop, web, and mobile apps.
What You'll Need
- A Google account. A personal Gmail account works, but a Google Workspace account is better if you plan to let other people in your organization use the app.
- A Google Cloud project. You can create one during the process; no billing is required for basic OAuth setup, but Google may ask you to verify your identity or add billing for certain scopes or higher usage.
- Basic knowledge of your app type: web server, Android, iOS, Chrome extension, or desktop. The client ID type must match where the app runs.
- Redirect URIs if your app uses a web flow. These are the exact URLs Google will send users back to after they sign in.
Step-by-Step
- Open the Google Cloud Console. Go to console.cloud.google.com and sign in with the Google account you want to own the project. The console layout can change slightly by version and region, but the main navigation stays similar.
- Create or select a project. Use the project selector at the top of the page. Click New Project, give it a clear name such as "Drive Integration", and click Create. Wait for the notification that the project is ready, then make sure it is selected.
- Enable the Google Drive API. Open the navigation menu, go to APIs & Services > Library. Search for "Google Drive API", open the result, and click Enable. If you also need to manage files in shared drives or use Google Picker, enable the relevant APIs while you are here.
- Configure the OAuth consent screen. Go to APIs & Services > OAuth consent screen. Choose External if anyone with a Google account can use the app, or Internal if only users in your Workspace organization can. Fill in the app name, user support email, and developer contact email. Save and continue.
- Add scopes. On the Scopes step, click Add or remove scopes. For basic Drive access, add the scope that matches what your app actually does, such as viewing file metadata or managing files. Add only the scopes you need; Google reviews sensitive scopes and may require verification before external users can authorize the app.
- Add test users if needed. While the consent screen is in testing mode, only accounts you list as test users can sign in. Add your own Google account and any colleagues who need to test. You can remove them later.
- Create the OAuth client ID. Go to APIs & Services > Credentials. Click Create Credentials and choose OAuth client ID. Select the application type that matches your app: Web application, Android, iOS, Chrome extension, or Desktop app.
- Fill in the type-specific details. For a web app, add authorized JavaScript origins (for example, your site's domain) and authorized redirect URIs (the exact callback URL your server uses). For Android, enter the package name and SHA-1 signing certificate fingerprint. For iOS, enter the bundle ID. For desktop apps, no redirect URI is usually required because the flow uses a loopback address.
- Copy the credentials. After you click Create, Google shows the client ID and client secret. Copy both and store them securely. The client secret is shown only at creation for some app types, so save it before closing the dialog. Never put the client secret in client-side code such as a public web page or a mobile app binary.
- Test the flow. Run your app's sign-in flow with a test user account. You should see the consent screen listing the scopes you added, and after approval the app receives an authorization code or token. If you see an error, check the redirect URI and the enabled APIs first.
Common Mistakes
- Wrong application type. A client ID created for a web app will not work in an Android or iOS app. Create a separate client ID for each platform.
- Redirect URI mismatch. The URI must match exactly, including http versus https, trailing slashes, and ports. A single difference causes a redirect_uri_mismatch error.
- Forgetting to enable the Drive API. The OAuth client can be created without enabling the API, but Drive calls will fail until it is enabled in the same project.
- Using the client secret in public code. Desktop and mobile apps cannot keep secrets confidential. Use the appropriate flow for public clients and do not embed secrets in distributed apps.
- Leaving the consent screen in testing. External apps in testing mode are limited to listed test users and may show warnings. Publish the app when you are ready for real users.
- Requesting too many scopes. Broad scopes trigger additional review and make users less likely to approve. Request the minimum needed.
Tips
- Use one Google Cloud project per environment (development, staging, production) so test credentials never reach production.
- Name client IDs clearly, such as "Drive Web Prod" or "Drive Android Debug", so you can identify them later.
- Keep a record of redirect URIs and authorized origins; changing your domain or callback path requires updating the client.
- If you use Google Workspace, an internal consent screen avoids the verification process for users in your organization.
- Review credentials periodically and delete client IDs that are no longer used.
Troubleshooting
If the sign-in flow fails, start with the simplest checks. Confirm the Drive API is enabled in the same project as the client ID. Verify that the redirect URI in your app matches the one in the console exactly. Make sure the account you are testing with is added as a test user while the consent screen is in testing mode. If you see an access blocked message, the app may be missing verification for the scopes you requested, or the user may not be allowed by your organization's policies. Sign out of all Google accounts and sign in again with the intended account, because multiple accounts in one browser can confuse the flow. If you changed the OAuth consent screen or scopes, users may need to re-authorize the app. For server-side apps, check that your server clock is correct and that you are exchanging the authorization code at the token endpoint with the correct client ID and secret. If the client secret was lost, create a new client ID or reset the secret in the Credentials page; the old secret cannot be recovered.
Frequently Asked Questions
Do I need a credit card to create an OAuth client ID?
No. Creating a project and OAuth client ID is free. Billing may be required for certain APIs or higher quotas, but basic Drive API usage does not require it.
Can I use one client ID for web and mobile?
No. Each platform needs its own client ID because the authentication flow and identifiers differ. Create separate credentials for web, Android, and iOS.
Why is my redirect URI rejected?
Google requires exact matches. Check for http versus https, trailing slashes, ports, and that the URI is listed under the correct client type. Localhost addresses are allowed for development.
How do I let other people use my app?
Publish the OAuth consent screen. For external apps with sensitive scopes, Google may require verification. Internal apps are limited to your Workspace organization.
Where do I find the client secret later?
For web apps, you can view and reset the secret in the Credentials page. For some other app types, the secret is only shown at creation, so store it securely.
Is the client ID secret?
The client ID is public and can be embedded in apps. The client secret must be kept confidential and never shipped in client-side code.