Auth0 Home Blog Docs

Implementing a custom login - avoiding the "auth0 is not defined" error



I got auth0 working on my angualr2 application with webpack by replacing

declare var auth0: any;

in the auth.service.ts with

let Auth0Lock = require('auth0-lock').default;

This allowed me to avoid the “auth0 is not defined” error and everything functioned correctly.

I am now trying to implement custom login. I used the code from the quickstart but replacing the “declare var auth0: any;” messes with the “//Configure Auth0” part of the code.

let Auth0Lock = require('auth0-lock').default;

export class Auth {

  // Configure Auth0
  auth0 = new auth0.WebAuth({
    domain: myConfig.domain,
    clientID: myConfig.clientID,
    redirectUri: myConfig.callbackURL,
    responseType: 'token id_token'

I’m guessing I need to replace the “//Configure Auth0” part with

lock = new Auth0Lock('myConfig.domain', 'myConfig.clientID', {});

and also define the redirectUrl and responseType in this line.

Can someone tell me how I should go about doing this?