This is a small app that demonstrates how easy it is to login users by using Lock Widget
.
You can read a quickstart guide for this sample here.
In order to run the example you need to just start a server. What we suggest is doing the following:
- Install node
- run
npm install -g serve
- run
serve
in the directory of the project.
Go to http://localhost:3000
and you'll see the app running :).
<!-- ===== ./index.html ===== -->
<head>
...
<!-- Auth0 lock script -->
<script src="//cdn.auth0.com/js/lock/10.1.0/lock.min.js"></script>
...
</head>
$(document).ready(function() {
var lock = null;
lock = new Auth0Lock(AUTH0_CLIENT_ID, AUTH0_DOMAIN, {
auth: {
params: { scope: 'openid email' } //Details: https://auth0.com/docs/scopes
}
});
$('.btn-login').click(function(e) {
e.preventDefault();
lock.show();
});
lock.on("authenticated", function(authResult) {
lock.getProfile(authResult.idToken, function(error, profile) {
if (error) {
// Handle error
return;
}
localStorage.setItem('id_token', authResult.idToken);
});
});
});