Search code examples
angularwebpackasp.net-coreauth0

Auth0, Angular 4 and ASP.NET Core


So I am trying to add authentication and authorization to my single page app that is running Angular 4 as frontend and ASP.net Core as backend, the issue I am running is that if I follow the tutorials on Auth0.com I cannot integrate it on my spa.

To replicate the issue, I add the auth.service.ts file to my project. Add the services as providers on my modules but when I try to reference it on my component to use the login and logout I get an error telling me this:

Error: Uncaught (in promise): TypeError: Cannot read property 'WebAuth' of undefined

I checked and I have all the services registered, but I cant find what it is about this.


Solution

  • I think, the problem could be in type of importing auth0 library. You should import it like this:

    import * as auth0 from 'auth0-js';