speakeasy: Google Token does not match generated token (clock is accurate)
I am running meteor app on Windows 10 with speakasy installed. time.is reports:
Your time is exact!The difference from Time.is was -0.039 seconds (±0.013 seconds).
However the tokens do not match - at all.
This is my code:
verifyToken() {
var myToken = this.state.authCode.trim()
let currentValidToken = speakeasy.totp({ secret: this.secretBase32, encoding: 'base32' });
let verified = speakeasy.time.verify({
secret: this.secretBase32,
encoding: 'base32',
token: myToken
})
console.log(`mySecret = [${this.secretBase32}] CVT = [${currentValidToken}] MYTOKEN = ${myToken} VERIFIED= [${verified}]`);
if (!verified) {
return swal({
title: "Invalid Code",
text: "You have 2 more attempts.",
showConfirmButton: true,
type: "error"
});
} else {
return swal({
title: "Jackpot!",
text: "You da man.",
showConfirmButton: true,
type: "success"
});
}
}
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 15
Commits related to this issue
- Use base32 for otpauth_url Fixes https://github.com/speakeasyjs/speakeasy/issues/99 — committed to harshjv/speakeasy by harshjv 6 years ago
Never mind, I got it working. It was simply an error in my code that I didn’t realize. That’s what happens when you stay up for over 12 hours and are coding at 3am.
Thanks for checking those. So the JS code is running on the client? The package doesn’t support (as in, it hasn’t been tested) usage on the client side - it’s exclusively for server side use. Do try to see if it works on the server and let me know what you find.