This repository demonstrates the use of Auth0 with Angular (with the @angular/cli) and a sample RESTHeart API with a protected route.
- Node.js with npm, Node >= 8, npm >= 5
- @angular/cli, >= 8
- Go to your Auth0 Dashboard: Applications section and click the "+ Create Application" button.
- Name your new app and select "Single Page Web Applications".
- In the Settings for your new Auth0 app, add
http://localhost:4200/callback
to the Allowed Callback URLs. - Add
http://localhost:4200
to both the Allowed Web Origins and Allowed Logout URLs. Click the "Save Changes" button. - If you'd like, you can set up some social connections. You can then enable them for your app in the Application options under the Connections tab. The example shown in the screenshot above uses username/password database, Facebook, Google, and Twitter.
Note: Set up your own social keys and do not leave social connections set to use Auth0 dev keys or you will encounter issues with token renewal.
This app uses RESTHeart API, please refer to www.restheart.com to know how to launch RESTHeart.
Clone this project. From the root directory, run the following commands to install dependencies for the server and client-side:
$ npm install
- Open
server/config.js.example
and remove.example
from the file name. Then replace[YOUR_AUTH0_DOMAIN]
with your Auth0 domain. - Open
src/app/environments/environment.example
and remove.example
from the file name. Then replace[YOUR_CLIENT_ID]
and[YOUR_AUTH0_DOMAIN]
with your Auth0 application's client ID and domain.
From the root of this project, run:
$ npm start
This will concurrently serve the Angular and API servers.
Auth0 helps you to:
- Add authentication with multiple authentication sources, either social like Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others, or enterprise identity systems like Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider.
- Add authentication through more traditional username/password databases.
- Add support for linking different user accounts with the same user.
- Support for generating signed Json Web Tokens to call your APIs and flow the user identity securely.
- Analytics of how, when and where users are logging in.
- Pull data from other sources and add it to the user profile, through JavaScript rules.
- Go to Auth0 and click Sign Up.
- Use Google, GitHub, or Microsoft Account to log in.