Hello Guys!!!, today we will be implemented the authentication in the Angular 2+ application within 5 mins using LoginRadius.
Configuring LoginRadius
To implement authentication in the angular app first let’s start with registering in the Loginradius and creating the application using LoginRadius CLI.
LoginRadius CLI Setup
Mac or Linux
- Install the tap via:
$ brew tap loginradius/tap - Then, you can install LR CLI via:
$ brew install lr
Other Platforms
- Download packaged binaries from the release page.
After installing the CLI, you can register into the LoginRadius via the below command.
$ lr register
This command will open the Loginradius in the browser to register yourself and create the app.
Once you successfully register you will be able to see the below message on the browser, you can close the tab and come back to the CLI.
You are Successfully Authenticated, Kindly Close this browser window and go back to CLI.
Get Your Application API Credentials
Once you login/register using the CLI, You can now run the lr get config command to get your API credentials.
Configuring Callback URLs
A callback URL is a URL in your application where LoginRadius redirects the user after they have authenticated. The callback URL for your app must be added to your Application Configuration. If this field is not set, users will be unable to log in to the application and get an error.
To get the list of whitelisted domains, you can run lr get domain command from the cmd prompt. And to add a domain in the list using lr add domain command.
If you are following this tutorial, you should set the http://localhost as a whitelisted domain. Check the below image for how to add the domain using LoginRadius CLI.
You can read more in detail about implementing authentication in Angular 2+ in this tutorial