TL;DR: OIDC in Electron apps centralises sign-in through browser-based federation, then returns users to the desktop app with stored session and refresh tokens, according to Descope. The pattern improves desktop user experience, but token storage, redirect handling, and session persistence still need identity governance controls rather than developer convenience.
At a glance
What this is: This is a developer guide to adding OIDC-based authentication to an Electron desktop app, with the key finding that browser-based federation plus secure token storage can simplify cross-app sign-in.
Why it matters: It matters because desktop authentication still creates IAM, token lifecycle, and session persistence decisions that affect human access governance, even when the app feels local and lightweight.
👉 Read Descope's guide to adding OIDC authentication in an Electron app
Context
OIDC in Electron apps is a human identity problem first: the application needs federated sign-in, a return path from browser to desktop, and token handling that does not weaken session control. Existing desktop login patterns often fragment authentication across local storage, custom code, and ad hoc redirects, which creates avoidable governance drift.
The core IAM issue is not whether the app can sign a user in. It is whether the authentication flow preserves session integrity, supports logout, and keeps token storage within an auditable lifecycle. For desktop applications, those decisions sit at the boundary between usability and access control, which is where many engineering teams under-design the identity layer.
Key questions
Q: How should security teams implement OIDC in Electron desktop apps?
A: Use an external browser for authentication, return users through a registered custom protocol, and keep token exchange, storage, and logout in a controlled service layer. The key is to separate interactive login from local session persistence so the desktop app never handles passwords directly and every token state change is explicit.
Q: Why do desktop apps make OIDC session governance harder?
A: Desktop apps often store session state locally, which extends the credential lifecycle beyond the browser and creates offboarding and revocation risk. If refresh tokens persist on device, IAM teams must govern them as durable credentials, not as temporary UI artefacts, because they can continue to authorize access after the user thinks they are signed out.
Q: What breaks when Electron apps rely on local token storage without strong controls?
A: Weak local token storage turns the desktop client into a recovery point for session theft, persistence, or stale access. Even if the tokens are encrypted, poor lifecycle handling can leave old sessions active, make logout incomplete, or hide privileged access from access reviews and incident response.
Q: How do IAM teams evaluate whether cross-app OIDC reuse is acceptable?
A: They should assess whether shared session state creates unacceptable blast radius across applications, devices, or business units. The decision depends on whether the organisation can enforce consistent logout, claim freshness, and application-level session boundaries; if it cannot, cross-app reuse should be constrained or segmented.
Technical breakdown
How OIDC redirect handling works in an Electron desktop app
Electron desktop apps usually cannot complete browser federation entirely inside the native runtime, so the app opens an external browser for authentication and waits for a redirect back through a custom protocol. In this pattern, the browser completes the OIDC flow, the authorization code returns to a scheme such as electron://auth/, and the app intercepts it to finish token exchange. That separation preserves the browser as the authentication surface while keeping the desktop app out of the password path. It also creates a dependency on redirect integrity, protocol registration, and correct code-to-token exchange handling.
Practical implication: register and test the redirect protocol early, because a broken return path turns federation into a support and security problem.
Token storage and refresh in desktop apps
Desktop applications cannot rely on browser cookies in the same way as web apps, so they need a local token persistence model. The guide uses encrypted storage through operating-system-backed secure storage plus a persistent settings layer, then refreshes session tokens when they expire. That approach reduces reauthentication friction, but it also means refresh token handling becomes part of the trust boundary. If storage is weak, extraction risk rises; if refresh logic is poor, users lose access or keep stale sessions alive longer than intended.
Practical implication: treat refresh tokens as governed credentials and define how they are stored, decrypted, rotated, and invalidated.
Session validation and logout in federated desktop authentication
A desktop sign-in flow is only as strong as its session validation and logout behaviour. In OIDC, logout should invalidate the active session state so the user is not silently reauthenticated when the app restarts or when another connected application still holds authority. The guide also shows profile retrieval from a /me endpoint, which means the app depends on identity assertions after login, not just a successful browser callback. That makes claim freshness, token validity, and failure handling part of the identity design rather than UI logic.
Practical implication: require explicit session checks and invalidation paths so identity state does not persist beyond intended use.
NHI Mgmt Group analysis
OIDC in desktop applications is still an identity governance problem, not just an application integration pattern. The browser handoff simplifies login, but it does not remove the need to govern session persistence, token storage, and logout semantics. Desktop apps often inherit the weakest parts of both worlds: browser federation on one side and local credential persistence on the other. Practitioners should treat the desktop client as part of the access surface, not as a harmless endpoint wrapper.
Token storage creates a local credential lifecycle that many teams under-model. Once session and refresh tokens are stored on device, they become non-human credentials in practice even when the subject is a person. That means revocation, expiry, and recovery need to be handled with the same seriousness as any other credentialed access path. The governance question is not whether encryption exists, but whether the token lifecycle is visible, bounded, and enforceable.
Cross-app session reuse is convenient, but it also concentrates risk across a broader identity estate. The article shows how one OIDC session can support access across multiple applications and platforms. That makes identity consistency stronger, but it also means a compromise or misconfiguration can propagate farther than a single app team expects. IAM programmes need to decide where shared SSO state ends and application-specific session control begins.
Electron authentication exposes a common assumption gap: if the login is browser-based, the desktop client is automatically secure. That assumption is only true when redirect handling, token persistence, and logout invalidation are all tightly governed. Without that, the application becomes a container for long-lived identity artefacts that are easy to overlook in code review but hard to recover after misuse. The practical conclusion is that desktop federation needs the same control discipline as any other federated access path.
For human identity programmes, desktop federation is one more place where lifecycle control must be explicit. Joiner-mover-leaver processes, session revocation, and reauthentication rules should not stop at the web application boundary. If the desktop app caches authority locally, then offboarding and session termination must account for those cached artefacts. Identity teams should therefore include desktop clients in access review and termination testing, not just in app onboarding.
From our research:
- 92% agree governing AI agents is critical to enterprise security, yet only 44% have implemented any policies to do so, according to the AI Agents: The New Attack Surface report.
- Only 52% of companies can track and audit the data their AI agents access, leaving 48% with a complete blind spot for compliance and breach investigation.
- That gap makes the Ultimate Guide to NHIs a useful forward reference for organisations formalising identity governance across machine and human access paths.
What this signals
Cross-app federation is becoming the default access pattern, but that does not reduce governance scope. When desktop, web, and mobile clients share one identity session, the control plane has to account for session invalidation, token lifecycle, and application-specific risk segmentation. Practitioners should map these flows against NIST AI Risk Management Framework-style governance thinking even when the workload is not AI-specific, because the same control logic applies to durable identity artefacts.
Desktop login flows expose a broader identity blast radius than many engineering teams expect. A browser-based OIDC handoff can look clean in development and still create hidden persistence on the endpoint through local storage, refresh tokens, and protocol handlers. The programme signal is simple: if you cannot explain where authority lives after sign-in, you do not yet have desktop identity governed end to end.
OIDC becomes stronger when it is paired with lifecycle discipline. Offboarding, session termination, and access review should all cover desktop clients explicitly, not as an afterthought to web SSO. For teams operating at scale, this is where structured identity lifecycle governance starts to matter more than the authentication flow itself, and where resources such as the Ultimate Guide to NHIs help align policy with execution.
For practitioners
- Validate redirect handling in the desktop trust boundary Test the custom protocol, callback parsing, and browser return path under normal and failure conditions so the app does not accept malformed or unexpected redirect inputs.
- Treat stored refresh tokens as governed credentials Classify on-device session and refresh tokens as sensitive identity material, and define storage, decryption, expiry, and revocation rules before release.
- Make logout an enforced invalidation event Ensure sign-out invalidates tokens across the full session chain, including any browser-held state and application-local persistence that could silently restore access.
- Add access review coverage for desktop clients Include Electron and other desktop applications in joiner-mover-leaver checks so cached sessions and token persistence are part of offboarding and recertification.
Key takeaways
- OIDC can simplify Electron authentication, but the desktop app still inherits session, token, and logout governance responsibilities.
- Local token persistence turns a convenience feature into a lifecycle control problem if revocation, expiry, and offboarding are not explicit.
- IAM teams should treat desktop federation as part of the access estate and include it in review, termination, and session validation processes.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST SP 800-63, NIST CSF 2.0 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-63 | SP 800-63C | OIDC federation and session handling map to digital identity federation guidance. |
| NIST CSF 2.0 | PR.AC-1 | The article is about controlled access through federated authentication. |
| NIST Zero Trust (SP 800-207) | Federated desktop access and token reuse fit Zero Trust access validation patterns. |
Map desktop sign-in and session controls to PR.AC and verify identity state is enforced consistently.
Key terms
- OIDC Federation: OIDC federation is a token-based trust model that lets one system accept identity assertions from another. It is commonly used to avoid static cross-environment credentials and to issue short-lived access based on trusted token claims. The control value depends on how tightly the trust relationships are governed.
- Custom protocol redirect: A custom protocol redirect is a non-web URL scheme that sends the user back into a desktop application after browser authentication. It is a convenience mechanism, but it also becomes part of the trust boundary because the app must safely parse and validate the returned data.
- Refresh token lifecycle: Refresh token lifecycle is the governance around how long a token remains valid, where it is stored, when it is renewed, and how it is revoked. In desktop apps, this lifecycle matters because persistence on device can outlast the user’s immediate session.
- Session persistence: The tendency for access to remain valid after the original authentication event has ended or been revoked upstream. In browser-centric incidents, this is the gap between killing the login and actually terminating the live SaaS or application session that the attacker is still using.
What's in the full article
Descope's full guide covers the operational detail this post intentionally leaves for the source:
- Step-by-step Electron configuration for OIDC redirect handling and browser handoff.
- Working auth-service.js patterns for authorization URL creation, token exchange, refresh, and profile lookup.
- Implementation details for SafeStorage and Electron-Settings token persistence across desktop sessions.
- Packaging and distribution guidance needed for deep linking and redirect behaviour to work correctly.
👉 Descope's full guide covers the Electron sample app setup, token handling, and packaging steps.
Deepen your knowledge
NHI governance, agentic AI identity, and machine identity lifecycle are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are responsible for identity security strategy or NHI governance in your organisation, it is worth exploring.
Published by the NHIMG editorial team on August 19, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org