This is a sample Express.js app that uses Passport.js and Asgardeo for authentication.
-
Clone this repository:
-
Sign up for a free Asgardeo account here.
-
Sign into Asgardeo console and navigate to Applications > New Application. Select Traditional Web Application
-
Select OpenID Connect (OIDC) as the protocol and complete the wizard popup by providing a suitable name and the authorized redirect URL
http://localhost:3000/oauth2/redirect
(Note: The authorized redirect URL determines where Asgardeo should send users after they successfully log in. Typically, this will be the web address where your application is hosted. For this guide, we'll usehttp://localhost:3000/oauth2/redirect
, as the sample application will be accessible at this URL). -
Once you create the application, you will be directed to the Quick Start tab of the created application which will guide you to integrate login to your application in several technologies (Note: Information available in the Quick Start tab of your app are required to configure Asgardeo in the Node.js app).
-
Navigate to User Management > Users and create a new user.
-
Create the .env file in the root of the project and add the environment variables as shown below:
ASGARDEO_ORGANISATION=<asgardeo_organization_name>
ASGARDEO_CLIENT_ID=<client_id>
ASGARDEO_CLIENT_SECRET=<client_secret>
- Install dependencies by running the following command in the root of the passport-asgardeo-sample project:
npm install
- Run the dev server:
npm start
-
Open your browser and navigate to
http://localhost:3000
. You will be redirected to the login page. Log in with the user you created in step 6. -
You will be redirected back to the Node.js app and see the index page with the user's information.