A complete example is available at https://github.com/keathmilligan/angular2-cli-auth0-example
The provided auth0 tutorial uses SystemJS, these notes outline how to integrate into an angular-cli or straight webpack project.
Create project as usual with "ng create".
Install auth0 packages & bootstrap:
npm install --save auth0-lock angular2-jwt bootstrap
Also install typings:
npm install --save-dev @types/auth0-lock
Add bootstrap CSS to angular-cli.json apps/styles section.
We will just import the auth0 modules we need rather than globally including them in index.html.
Add "allowSyntheticDefaultImports": true
to app/tsconfig.json. Hat tip: mikeesouth.
Create AuthService per auth0 example, change the declar var
line in auth.service.ts to an import:
import Auth0Lock from 'auth0-lock';
Remember to add the service to app.module.ts providers.
Add http://localhost:4200 to the Allowed Hosts (CORS) section in the auth0 client dashboard.
Remove auth0-lock, install auth0-js:
npm uninstall --save auth0-lock
npm uninstall --save-dev @types/auth0-lock
npm install --save auth0-js
@types/auth0-js is currently broken. Use the auth0-js.d.ts in this gist, place it in your src folder.
auth.service.ts:
import Auth0 from 'auth0-js';