Must use AlgorithmSHA1 with iOS version of Google Authenticator
yghazi opened this issue · comments
yghazi commented
key,_ := totp.Generate(totp.GenerateOpts{
AccountName: "XYZ Test",
Issuer: "some.domain.com",
Algorithm: otp.AlgorithmSHA512,
})
var buff bytes.Buffer
img, _ := key.Image(256,256)
f, _ := os.Create("test.html")
png.Encode(&buff, img)
encodedString := base64.StdEncoding.EncodeToString(buff.Bytes())
htmlImage := "<img src=\"data:image/png;base64," + encodedString + "\" />"
l, err := f.WriteString(htmlImage)
if err != nil {
log.Println(err)
}
The resultant test.html
shows a QR code that provides correct codes when scanned with Google Authenticator on Android, but not on iPhone.
Paul Querna commented
Try using Algorithm: otp.AlgorithmSHA1
- I think the iOS version supports less algorithms for the TOTP.