# OAuth2 Login for JetBrains IDE Plugins

**URL:** <https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387>\
**Category:** Announcements\
**Tags:** blog, api, plugin-development\
**Created:** [June 1, 2026, 2:35pm UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387 "2026-06-01T14:35:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakub.chrzanowski](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/jakub.chrzanowski/32/38_2.png) [@jakub.chrzanowski](https://platform.jetbrains.com/u/jakub.chrzanowski)\
**Post date:** [June 1, 2026, 2:35pm UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/1 "2026-06-01T14:35:09Z")

</div>

Hi, folks!

I published a new tutorial on implementing OAuth2 login in JetBrains IDE plugins without asking users to paste personal access tokens into settings.

The example uses GitHub, but the plugin-side pattern is reusable:

- open the provider login in the browser
- receive the callback through the IDE
- validate `state`
- exchange the code with PKCE
- store the token in `PasswordSafe`
- use the token for API calls

[![](https://us1.discourse-cdn.com/flex001/uploads/jetbrains_platform/original/2X/4/43b65150a8162ccba12aee94aa9999cfa449d678.jpeg "Stop Pasting Tokens: OAuth2 for JetBrains IDE Plugins") ](https://www.youtube.com/watch?v=Qt8kLAQQYJE)

If you prefer to read, there’s also a blog post 👇

> **[Stop Pasting Tokens: OAuth2 Login for JetBrains IDE Plugins | The JetBrains...](https://blog.jetbrains.com/platform/2026/06/stop-pasting-tokens-oauth2-login-for-jetbrains-ide-plugins/)**
>
> The moment a plugin needs account data, a simple API call turns into an authentication problem. The bad shortcut is familiar: ask the user to create a personal access token (PAT), make them paste it i

Sample code: [intellij-sdk-docs/code\_samples/oauth2 at main · JetBrains/intellij-sdk-docs · GitHub](https://github.com/JetBrains/intellij-sdk-docs/tree/main/code_samples/oauth2)

I’d be interested to hear how others handle OAuth2 in plugins, especially around multiple accounts, token refresh, and provider-specific quirks.

---

<div class="post-metadata">

**Author:** ![jgafner](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/jgafner/32/78_2.png) [@jgafner](https://platform.jetbrains.com/u/jgafner)\
**Post date:** [June 1, 2026, 6:13pm UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/2 "2026-06-01T18:13:24Z")

</div>

I implemented exactly like that for my AZD (azure DevOps) few weeks ago, unfortunately not all variants and external tools support oath2. For example azure DevOps server (on prem) and also Codecov, so I kept also the PAT as an option for the end user.

Also, just got a request from a user to allow authentication with azure cli so I guess I ll have to support that as well…

But the example of GitHub in the IntelliJ community was super helpful and revealing on how to support Oath2

---

<div class="post-metadata">

**Author:** ![zielu](https://avatars.discourse-cdn.com/v4/letter/z/e47774/32.png) [@zielu](https://platform.jetbrains.com/u/zielu)\
**Post date:** [August 5, 2026, 7:17pm UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/3 "2026-08-05T19:17:02Z")

</div>

So how to you solve exactly this point from sample readme:

```auto
- do not rely on a bundled client secret.

```

Because it looks to me it is required by GH API, what is the alternative ?

---

<div class="post-metadata">

**Author:** ![jakub.chrzanowski](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/jakub.chrzanowski/32/38_2.png) [@jakub.chrzanowski](https://platform.jetbrains.com/u/jakub.chrzanowski)\
**Post date:** [August 10, 2026, 11:47am UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/4 "2026-08-10T11:47:36Z")

</div>

For GitHub specifically, the answer depends on the OAuth flow you use.

For a desktop/native app like an IDE plugin, you should treat it as a public client, which means you cannot really keep a client secret secret. If you bundle it with the plugin, anyone can extract it.

GitHub’s current guidance is to use Authorization Code + PKCE for public clients. In that case, the client secret is not what protects the flow; PKCE does that job instead. GitHub also supports the Device Flow, which does not require a client secret at all, although GitHub recommends PKCE over Device Flow when you can use a browser-based authorization flow. (⁠[GitHub Docs](https://docs.github.com/en/enterprise-cloud%40latest/apps/oauth-apps/building-oauth-apps/best-practices-for-creating-an-oauth-app?utm_source=chatgpt.com))

So by “do not rely on a bundled client secret,” I mean: don’t treat a secret shipped inside the plugin as an actual secret or as your security boundary.

If a provider really requires a confidential client secret and does not support PKCE/public clients, the usual alternative is to keep that secret on your own backend and let the backend perform the sensitive exchange.

---

<div class="post-metadata">

**Author:** ![Adel.Faizrakhmanov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/adel.faizrakhmanov/32/672_2.png) [@Adel.Faizrakhmanov](https://platform.jetbrains.com/u/Adel.Faizrakhmanov)\
**Post date:** [August 27, 2026, 9:37am UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/5 "2026-08-27T09:37:35Z")

</div>

OAuth apps have authorized callback URLs. But the IDE’s built-in web server has a configurable port. How can we set up our OAuth callbacks in that case?

---

<div class="post-metadata">

**Author:** ![jakub.chrzanowski](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/jakub.chrzanowski/32/38_2.png) [@jakub.chrzanowski](https://platform.jetbrains.com/u/jakub.chrzanowski)\
**Post date:** [August 27, 2026, 2:22pm UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/6 "2026-08-27T14:22:34Z")

</div>

In general, we should specify multiple ports, starting from the default one — as they rotate if you have multiple IDEs open:

- localhost:63342
- localhost:63343
- localhost:63344
- …

But for custom ports — that won’t work. ☹

---

<div class="post-metadata">

**Author:** ![Adel.Faizrakhmanov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/adel.faizrakhmanov/32/672_2.png) [@Adel.Faizrakhmanov](https://platform.jetbrains.com/u/Adel.Faizrakhmanov)\
**Post date:** [September 1, 2026, 2:46pm UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/7 "2026-09-01T14:46:26Z")

</div>

I’ve found out that the port can be omitted in the settings. At least for GitHub and Sentry OAuth apps. So it’s not a problem.

BTW, why “localhost” instead of"127.0.0.1"? I saw some recommendations to use 127.0.0.1.

---

<div class="post-metadata">

**Author:** ![robert.novotny](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/robert.novotny/32/2046_2.png) [@robert.novotny](https://platform.jetbrains.com/u/robert.novotny)\
**Post date:** [September 2, 2026, 8:06am UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/8 "2026-09-02T08:06:51Z")

</div>

Thank you for pointing this out. Looks like parts of the [OAuth 2.0 Specs](https://datatracker.ietf.org/doc/html/rfc8252#section-8.3) recommend literal address.

---

<div class="post-metadata">

**Author:** ![arshrao090](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/arshrao090/32/3347_2.png) [@arshrao090](https://platform.jetbrains.com/u/arshrao090)\
**Post date:** [September 5, 2026, 7:15am UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/9 "2026-09-05T07:15:52Z")

</div>

The PKCE approach makes sense for an IDE plugin since anything bundled with the plugin shouldn’t really be treated as a secret. The rotating localhost ports are also an interesting part of the setup, especially when multiple IDE instances are running. I’ve been looking at different tools that generate personalized paths from user input as well[,](https://destinymatrics.com) and it’s interesting how the same idea of handling user-specific data comes up in very different types of applications. Has anyone found a clean way to handle the rotating callback ports without having to register a large range of URLs?

---

<div class="post-metadata">

**Author:** ![Adel.Faizrakhmanov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/adel.faizrakhmanov/32/672_2.png) [@Adel.Faizrakhmanov](https://platform.jetbrains.com/u/Adel.Faizrakhmanov)\
**Post date:** [September 17, 2026, 7:07am UTC](https://platform.jetbrains.com/t/oauth2-login-for-jetbrains-ide-plugins/4387/10 "2026-09-17T07:07:59Z")

</div>

As I see, many OAuth2 services let you register a callback URL without a port, and then you can use any port you want.
