# Is it ok to put a client secret in a "Desktop app"?

**URL:** <https://discuss.google.dev/t/is-it-ok-to-put-a-client-secret-in-a-desktop-app/296820>\
**Category:** Q&A\
**Tags:** gmail\
**Created:** [December 13, 2025, 7:55pm UTC](https://discuss.google.dev/t/is-it-ok-to-put-a-client-secret-in-a-desktop-app/296820 "2025-12-13T19:55:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mniesen](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/mniesen/32/185613_2.png) [@mniesen](https://discuss.google.dev/u/mniesen)\
**Post date:** [December 13, 2025, 7:55pm UTC](https://discuss.google.dev/t/is-it-ok-to-put-a-client-secret-in-a-desktop-app/296820/1 "2025-12-13T19:55:25Z")

</div>

Hi

I was looking at [Java quickstart &nbsp;|&nbsp; Gmail &nbsp;|&nbsp; Google for Developers](https://developers.google.com/workspace/gmail/api/quickstart/java) but I have a question. Why do they include a credentials.json file with client secret.  
If someone has someone else’s credentials.json file, can it then be used for bad purposes? Because the login popup will show a name of an app, while another program actually opened it.

I was told to never put a client secret in a program that was running as a client.

Kind regards  
Michiel Niesen

---

<div class="post-metadata">

**Author:** ![Causevay](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/causevay/32/219242_2.png) [@Causevay](https://discuss.google.dev/u/Causevay)\
**Post date:** [December 15, 2025, 2:18pm UTC](https://discuss.google.dev/t/is-it-ok-to-put-a-client-secret-in-a-desktop-app/296820/2 "2025-12-15T14:18:32Z")

</div>

Yes — if someone gets your credentials.json with a client secret, they can impersonate your app and potentially trick users, abuse your API quota, or trigger OAuth flows showing your app name. That’s why client secrets should never be in client-side apps.

For safe client apps, use OAuth with PKCE (no secret) or run OAuth on a secure backend.

---

<div class="post-metadata">

**Author:** ![mniesen](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/mniesen/32/185613_2.png) [@mniesen](https://discuss.google.dev/u/mniesen)\
**Post date:** [December 15, 2025, 6:08pm UTC](https://discuss.google.dev/t/is-it-ok-to-put-a-client-secret-in-a-desktop-app/296820/3 "2025-12-15T18:08:45Z")

</div>

Great, that confirms my understanding.

However when using PKCE and not providing a client\_secret, I get:  
{

```
"error": "invalid_request",

"error_description": "client_secret is missing."

```

}  
when trying to exchange my code for an access token.

Any idea how to get this working without a client secret?

---

<div class="post-metadata">

**Author:** ![Causevay](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/causevay/32/219242_2.png) [@Causevay](https://discuss.google.dev/u/Causevay)\
**Post date:** [December 15, 2025, 9:03pm UTC](https://discuss.google.dev/t/is-it-ok-to-put-a-client-secret-in-a-desktop-app/296820/4 "2025-12-15T21:03:35Z")

</div>

**Do not use web app and remember to include**

- **client\_id**

- **code**

- **code\_verifier**

- **redirect\_uri**

- **grant\_type=authorization\_code**

**Do NOT include:** client\_secret

google expects POST [https://oauth2.googleapis.com/token](https://oauth2.googleapis.com/token)

Content-Type: application/x-www-form-urlencoded

client\_id=YOUR\_CLIENT\_ID

&code=AUTH\_CODE

&code\_verifier=ORIGINAL\_VERIFIER

&redirect\_uri=YOUR\_REDIRECT\_URI

&grant\_type=authorization\_code

your mistake was

- Created a **Web App OAuth client**

- Tried to “just not send” the client secret

- Google rejects it with:

“client\_secret is missing.”

---

<div class="post-metadata">

**Author:** ![mniesen](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/mniesen/32/185613_2.png) [@mniesen](https://discuss.google.dev/u/mniesen)\
**Post date:** [December 15, 2025, 9:28pm UTC](https://discuss.google.dev/t/is-it-ok-to-put-a-client-secret-in-a-desktop-app/296820/5 "2025-12-15T21:28:06Z")

</div>

No, I used a desktop app. This article [Google OAuth2/OIDC and PKCE: Understanding Client Secret Requirements](https://ktaka.blog.ccmp.jp/2025/07/oogle-oauth2-and-pkce-understanding.html) describes exactly what problems i’m having.

Also I find a lot of people online that also say that it doesn’t work with a Desktop app application type. I used PKCE an didn’t provide a client\_secret and then I get the error message.

---

<div class="post-metadata">

**Author:** ![Causevay](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/causevay/32/219242_2.png) [@Causevay](https://discuss.google.dev/u/Causevay)\
**Post date:** [December 15, 2025, 10:04pm UTC](https://discuss.google.dev/t/is-it-ok-to-put-a-client-secret-in-a-desktop-app/296820/6 "2025-12-15T22:04:44Z")

</div>

Although OAuth 2.0 + PKCE allows public clients to omit a client\_secret, Google’s OAuth token endpoint often still requires a client\_secret for Desktop app OAuth clients, even when PKCE is correctly implemented. This is especially common with APIs like Gmail.

This means:

- Registering the client as a Desktop app

- Using PKCE correctly

- Omitting client\_secret

still result in:

- invalid\_request: client\_secret is missing

**What works in practice**

Include the client\_secret even with PKCE (this is what Google client libraries effectively do), or Perform the authorization code exchange on a backend where the secret can be stored securely

**TO SUM IT UP**

This isn’t a violation of the OAuth spec on the client side, but a Google-specific implementation/policy limitation. Secret-less PKCE for Desktop apps is not consistently supported across Google APIs at this time.

---

<div class="post-metadata">

**Author:** ![dennisameling](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/dennisameling/32/271215_2.png) [@dennisameling](https://discuss.google.dev/u/dennisameling)\
**Post date:** [July 19, 2026, 10:17am UTC](https://discuss.google.dev/t/is-it-ok-to-put-a-client-secret-in-a-desktop-app/296820/7 "2026-07-19T10:17:20Z")

</div>

Super confusing indeed. Google recommends against storing client secrets in source code, but there’s [this official Google documentation](https://developers.google.com/identity/protocols/oauth2#installed) that says the following about “Installed applications”, in this case desktop apps:

> The Google OAuth 2.0 endpoint supports applications that are installed on devices such as computers, mobile devices, and tablets. When you create a client ID through the [Google API Console](https://console.developers.google.com/), specify that this is an Installed application, then select Android, Chrome Extension, iOS, or Desktop app as the application type.
> 
> The process results in a client ID and, in some cases, a client secret, **which you embed in the source code of your application**. (In this context, the client secret is obviously not treated as a secret.)
