Import auth0 issue - july 16 migration

We are migrating from Auth0-Lock 10.x to Universal Login. Our stack is Node.js server and React client.

Before, we used auth0-lock version 10.2.2:

import Auth0Lock from ‘auth0-lock’
lock = new Auth0Lock(clientId, domain, cfg)

Now, we are trying to use auth0-js version 9.6.1:

const AuthenticationClient = require(‘auth0’).AuthenticationClient;
var auth0Client = new AuthenticationClient({domain, clientId});
lock = new auth0Client.WebAuth()

We get the webpack build error:

ERROR in ./src/utils/AuthService.js
Module not found: Error: Can’t resolve ‘auth0’ in ‘/Users/jacobmyers/projects/project/src/utils’

We tried changing require(‘auth0’) to:
import * as auth0 from ‘auth0-js’

Then the build works, but we get the error:
AuthenticationClient is not a constructor

How do we import the auth0 / AuthenticationClient object correctly?
Thank you.

:wave: @Jacob12340987 are you moving your react app from Lock to Universal Login?

If your previous configuration with Lock looked something like this: this.lock = new Auth0Lock(this.clientId, this.domain, lockCfg);

moving to [auth0js](https://auth0.com/docs/libraries/auth0js/v9) would take the same parameters as initializing Lock:

var webAuth = new auth0.WebAuth({
  domain: this.domain,
  clientID: this.clientId,
  ...
});

there is more information available here

Does the React client interact with the nodejs api server? This may also be helpful:

Please let me know if I understood your use case correctly.

I am attempting to migrate our platform from Auth0-Lock 10.x to Universal Login to move towards compliance with deprecations July 16th, 2018. Our stack is Node.js server and React client.

Previously, our Auth0 client-side Lock service looked something like this
(package.json > "auth0-lock": "^10.2.2"):

import Auth0Lock from ‘auth0-lock’

this.lock = new Auth0Lock(this.clientId, this.domain, lockCfg);

After our attempted migration, the Auth0 client service looks like (package.json > “auth0-js”: “^9.6.1”):

const AuthenticationClient = require('auth0').AuthenticationClient;
...
var auth0Client = new AuthenticationClient({
  domain: `${process.env.AUTH0_DOMAIN}`,
  clientId: `${process.env.AUTH0_CLIENT_ID}`
});
...
this.lock = new auth0Client.WebAuth({

This results in the following webpack builder error:

ERROR in ./src/utils/AuthService.js
Module not found: Error: Can't resolve 'auth0' in '/Users/jacobmyers/projects/sumergeme2/src/utils'

I also tried changing the require(‘auth0’) statement to:
import * as auth0 from 'auth0-js'
Then the build works, but i get the error:
AuthenticationClient is not a constructor

Please help me get this migration working! Thank you.

Kim, thank you for the response. The problem we’re facing is prior to parameterizing the Lock. Our problem is getting the reference to the auth0 object so that we can run this statement:

var webAuth = new auth0.WebAuth();

The documentation you refer to says to import Auth0-js and run the ‘new auth0.WebAuth()’ statement. But, it says nothing of how to import the auth0 object so we can call new auth0.WebAuth().

require(‘auth0’) does not work to import the auth0 object. When trying this way, auth0.AuthenticationClient is not a valid property.

How can we successfully import the auth0 object?

Please ignore. The issue has been addressed.

1 Like