How to Build a JavaFX Desktop App with OIDC Authentication

How to Build a JavaFX Desktop App with OIDC Authentication

This tutorial shows you how to add OAuth 2.0 authorization and OIDC authentication in a JavaFX desktop app.

Aÿaz Péraçhaa

HI Andrew,

Thanks for a fantastic tutorial. Bravo!!

I have one question. I am able to compile the code and run it.

My user agent is running but giving me a blank screen. I am unable to authenticate with OKTA (I verified my URL is OK, I copied and pasted it in Chrome and its working, the only issue is with user agent):

Can you please give me some idea. Thanks

Matt Raible

I just tried running this example and it worked for me. The only thing that was difficult was I had to use “” as my oktaDomain in, with no prefix or suffix. I’m on a Mac though, and it looks like you’re on Windows. I’m guessing you’re using Oracle JDK 8 or the project wouldn’t even compile.

eyeshani addhunter

This is simply a wonderful love this lovely display, definitely an inspiration. Wonderful and informative web site.We at
Propertyhunters shifted this service to a level much higher than the broker concept. you can see more
details like this article Apartments for sale in Doha Qatar

Pierre Tardy

Hello, two questions from a security point of view:

I understand that the redirect URL is localhost. How do you protect against Man in the middle in this case (we don’t control localhost)

How do you protect the secret key in your JFX app?

It looks like any hacker with access to my app will be able to generate a rogue app that steal users bearer token.

Matt Raible

Hello Pierre,

Your first question is a good one. You could try using instead of localhost. In most cases, the end user controls localhost, so I’m not sure “we don’t control localhost” is accurate.

As far as the secret key - you should never distribute one with your app. It should be possible to use authorization code flow with PKCE so you don’t need a client secret. However, the Microsoft library used in this tutorial hasn’t been updated since 2018 so I doubt it supports PKCE.

Ernesto Ivan Contreras Navarro

Did you find the solution to this problem? I’m making a javaFx application that uses okta, but I still get a blank page just like you