ksh*_*hen 6 authentication google-authentication node.js coffeescript
我正在尝试在我的网站上使用Google身份验证器设置双因素身份验证.我能够生成工作代码,但是当我将图像URL插入页面时,我在Chrome检查器中收到以下错误:
GET https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/MyLabel?secret=THESECRET 400 (Bad Request)
Run Code Online (Sandbox Code Playgroud)
生成QR码的代码:
try
key = crypto.randomBytes(10).toString('hex')
catch error
console.log "error generating code: #{error}"
encoded = base32.encode(key)
label = encodeURIComponent "MyLabel"
uri = "otpauth://totp/#{label}?secret=#{encoded}"
url = "https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=#{uri}"
Run Code Online (Sandbox Code Playgroud)
插入图像的客户端jQuery:
img = $("<img>").attr("src", url)
$("#qr_box").html("")
$("#qr_box").append(img)
Run Code Online (Sandbox Code Playgroud)
这导致页面上出现以下HTML:
<img src="https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/MyLabel?secret=THESECRET">
Run Code Online (Sandbox Code Playgroud)
可以在新选项卡中打开图像而不会出现问题.图像仅在我的页面中成功显示约1/10的时间; 其他时候Chrome给了400.我在这里错过了一些明显的东西吗?
| 归档时间: |
|
| 查看次数: |
1627 次 |
| 最近记录: |