Having problems with initializing SSO using the-definitive-guide-to-single-sign-on.pdf

Greetings,

I have struggled with adapting the SSO into my app for the last several weeks. I need to implement the Lock widget and simply return the user’s email address. This should be simple, Right?

After weeks of trying different methods and following all types of tutorials, I found the definitive guide to single-sign-on, and have tried to adapt the steps as described in the document.

On page 56, where we define the scripts within the html file as described by these statements.

In my html file these are the scripts that I have included. As you can see I’ve implemented the latest versions of these scripts.

The SolePro.js is my apps.js and contains the steps as defined in the definitive guide.

The last script in my html file is as follows:

<script type="text/javascript">
	window.onload = async () => {
		console.log("inside html script window.onload async function...")
		configureClient()
	}
</script>	

So when Windows loads my file, it calls the function configureClient()

On Page 57 is shows the following lines to be implemented within the apps.js.

var lock = new Auth0Lock(‘YOUR-CLIENT-ID’, ‘YOUR-DOMAIN’);
var webAuth = new auth0.WebAuth({domain:‘YOUR-DOMAIN’, clientID:‘YOUR-CLIENT-ID’});
var auth = new Auth0({domain:‘YOUR-DOMAIN’, clientID:‘YOUR-CLIENT-ID’});

In the SolePro.js, here’s the code that is used to define the configureClient(), which creates auth0 instance for the config values stored in a json file.

const fetchAuthConfig = () => fetch(“./public/auth_config.json”)

const configureClient = async () => {
const response = await fetchAuthConfig()
const config = await response.json()

auth0 = await createAuth0Client({
	domain: config.domain,
	client_id: config.clientId
})
initAuth0(auth0)

}

The initAuth0(auth0) is called which define the variables described above on page 57. The only line that worked properly was the lock object. I placed try{} blocks around the subsequent lines to show the errors that occurred. I pass the auth0 object to initAuth0 function and then use that value in a local variable inside initAuth0 as follows:

objAuth0 = q_auth0

try {
	var objWebAuth = new objAuth0.WebAuth({domain:objAuth0.options.domain, clientID:objAuth0.options.clientId});
}
catch(err) {
	console.log("new WebAuth error: " + err)
}

try {
	var objAuth = new Auth0({domain:objAuth0.options.domain, clientID:objAuth0.options.clientId});
}
catch(err) {
	console.log("new Auth0 error: " + err)
}

new WebAuth error: TypeError: objAuth0.WebAuth is not a constructor
new Auth0 error: TypeError: Auth0 is not a constructor

Within the SoloPro.js file here’s the code that defines the configureClient. Within the root Directory of the app there is a public directory which contains the Client and Domain values as defined in the Auth0 application.

What am I missing?

I’m under the assumption that auth0 is defined when I createAuth0Client, and that that object is used to create the property of WebAuth.

var webAuth = new auth0.WebAuth

In the definitive guide there isn’t any type of reference as to what creates the auth0 object as part of the new auth0.WebAuth. So I’m not sure the word is correct for “definitive”.

All I need is to get the lock widget to supply the social apps and allow the user to login and return the email, but I keep getting stuck and certain steps along the way. The last tutorial I followed get me up to the lock widget, but errored out with a 404 error getSSOData.

I searched that out and was informed that I should set the rememberLastLogin: false, or rather disabled, but there wasn’t any instruction as to set the value from within the Applications on Auth0, or to modify the lock object prior to lock.show(), which is where it was erroring out.

Can anyone help me?

Thanks,

Scott.