Please include the following information in your post:
Auth0.js
SDK Version: v9.18.0
Platform Version:** e.g. Node 12.19.0
Code Snippets/Error Messages/Supporting Details/Screenshots:
Hi, I’m developing the login page use Auth0.js.
I tried to implement simple page as below:
<body>
<button id="pwd-start">Passwordless Start</button>
<button id="pwd-verify">Passwordless Verify</button>
<button id="logout">Log out</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/latest/js.cookie.min.js"></script>
<script src="https://cdn.auth0.com/js/auth0/9.18.0/auth0.min.js"></script>
<script src="/cordova-auth0-plugin.js"></script>
<script type="application/javascript">
const pwdStartButton = document.getElementById('pwd-start');
const pwdVerifyButton = document.getElementById('pwd-verify');
const logoutButton = document.getElementById('logout');
const options = {
domain: 'xxxxx.au.auth0.com',
clientID: 'xxxxxxxx',
redirectUri: 'http://localhost:3000/login.html',
responseType: 'id_token',
audience: 'https://xxxxx-c/api',
scope: "openid profile email"
};
var passwordlessEmail;
pwdStartButton.addEventListener('click', () => {
const webAuth = new auth0.WebAuth({
...options,
responseType: 'id_token token'
});
const phone = prompt('Enter your phone');
if (phone) {
webAuth.passwordlessStart(
{
connection: 'sms',
send: 'code',
phoneNumber: phone
},
(err, result) => {
if (err) return console.error(err);
console.log(result);
passwordlessEmail = phone;
alert('Done! Check your phone');
}
);
}
});
pwdVerifyButton.addEventListener('click', () => {
const webAuth = new auth0.WebAuth({
...options,
responseType: 'id_token token'
});
const verificationCode = prompt('Enter the code');
if (!passwordlessEmail) {
passwordlessEmail = prompt(
'Enter the email address to which the code was sent'
);
}
if (verificationCode) {
webAuth.passwordlessLogin(
{
connection: 'sms',
verificationCode,
phoneNumber: passwordlessEmail,
onRedirecting: done => {
console.log('Redirecting passwordless...');
done();
}
},
(err, res) => {
if (err) console.error(err);
console.log(res);
}
);
}
});
logoutButton.addEventListener('click', () => {
const webAuth = new auth0.WebAuth(options);
webAuth.logout({ returnTo: 'http://localhost:3000/login.html' });
});
window.onload = function() {
const webAuth = new auth0.WebAuth(options);
webAuth.parseHash((err, data) => {
console.log(data);
window.location.hash = '';
});
};
</script>
</body>
But when click “Passwordless Start” button with request:/passwordless/start
Then response:
{“error”:“unauthorized_client”,“error_description”:“Client authentication is required”}
I’ve been looking at the documentation and have found nothing related to this.