Go To Dashboard

Java


This guide will show you how to implement the user authentication in a Java application. For this tutorial, we will use the Java demo from GitHub and show you step by step how to run it.

Prerequisites

This tutorial assumes you have:

  • Basic knowledge of HTML/CSS
  • java installed on your system

Setup Your Dashboard

Get your credentials and whitelist your application domain as explained in this section. This is a mandatory step to successfully implement and run the demo.

Start with Auth Page (IDX) demo

  1. You can clone the Auth Page demo repository on your system using below commands:

    With SSH

    git clone git@github.com:LoginRadius/login-page-demos.git

    With https

    git clone https://github.com/LoginRadius/login-page-demos.git
  2. Now move to the directory Java demo by running the following command using the terminal

cd login-page-demo/java-idx-demo/

and Open/import java-idx-demo in your java IDE (Eclipse).

This is the file structure you will get in the Java demo, let's see what each file does

  • demo folder - Contains all the HTML, CSS and JS file to create UI for the test application.

  • static folder - Contains all the CSS and JS file to create UI for the test application.

  • java folder - Contains server side code and routing API to be used in demo

  • templates folder - contains the HTML template for Login and profile page

.
.project
pom.xml
README.md
src
| -- main
| -- |--- |java/
| -- |--- |resources/
| -- |--- |-- application.properties
| -- |--- |-- static
| -- |--- |-- templates
| -- |--- |-- --- index.html
| -- |--- |-- --- profile.html
  1. You need to add your LoginRadius credentials in the demo app to communicate with LoginRadius SDK
  • Server side: java-idx-demo/src/main/resources/application.properties
server.port= 8080
app.apikey=xxxxxxxxxx //Add api key
app.apisecret=xxxxxxxxx //Add api secret
  • Client side: java-idx-demo/src/main/resources/static/js/options.js
commonOptions.apiKey = "<LoginRadius API Key>"; //Add api key
commonOptions.appName = "<App Name>"; //Add app name
  1. Running application

Run this application on your java IDE and after successful build

Then visit http://localhost:3000/demo from your local browser and you will see the application running. Once you click on login button it will redirect you to auth page.

Java-app

Features implemented in demo

  • Login with Auth Page (IDX)
  • Registration with Auth Page (IDX)
  • Email Verification
  • Forgot Password
  • Reset Password

Discover More

Discover More on

How To Guides

Edit on GitHub