React sample web application to integrate with Asgardeo for B2C usecases
A live preview of this demo is available at
- Vercel: https://asgardeo-react-sample-app.vercel.app
- Netlify: https://kaleidoscopic-medovik-1bf3fc.netlify.app
- Sign up to Asgardeo as a new user
- Sign In and Sign Out of the application
- Home page with the references and guides
- The user roles Manager and User.
- Manager can view the Profile and API call pages
- User can view the Profile page
- User Profile to view and update details.
- API call page to send an API call.
- User can set up the preferred option for second factor authentication
Create the application
-
Access Asgardeo at https://console.asgardeo.io/ and log in.
-
Click Applications in the left navigation menu.
-
Create a new application
- Select Single Page Application
- Fill the details and click Create.
- Name: React-App
- Authorized Redirect URLs: https://localhost:3000 (Use the Add New option)
Add Application Roles
- Navigate to User Management > Groups from the side panel
- Create a Group and add users
- Create a Role in the application
- Navigate to User Management > Roles from the side panel and assign the group to the role
- Allow the application_roles attribute in the application
Add Second Factor Authentication (Optional)
-
Navigate to the Sign in methods of the application
-
Add the second step authentication
- Clone the repository.
git clone https://github.com/dasuni-30/asgardeo-react-sample-app.git
- Install the dependencies.
npm install
- Create a
.env
file based on the.env.example
file.
cp .env.example .env
- Update the values in the
.env
file based on your requirements.
# The port number on which the client application will run
PORT=3000
# The base URL of the server's API that the client application will communicate with
# E.g., http://localhost:5000
REACT_APP_API_ENDPOINT=<add-server-api-url>
# The client ID for the Asgardeo Single Page Application (SPA) app
REACT_APP_CLIENT_ID=<add-asgardeo-spa-app-client-id-here>
# The base URL for the client application
# E.g., http://localhost:3000
REACT_APP_CLIENT_BASE_URL=<add-client-app-base-url-here>
# The base URL for the Asgardeo organization's API
# E.g., https://api.asgardeo.io/t/your-org
REACT_APP_ASGARDEO_BASE_URL=<add-asgardeo-org-base-url-here>
# The sign-up URL for the Asgardeo organization
REACT_APP_SIGN_UP_URL=<asgardeo-sign-up-url>
# The application name for the Asgardeo application
REACT_APP_APPLICATION_NAME=<application-name>
# The organization name for the Asgardeo
REACT_APP_ORG_NAME=<org-name>
- Start the development server.
npm start
This will start the app on http://localhost:3000.