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
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)
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.
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?
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, 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?