我想使用 Google Authenticator在我们的应用程序中用于登录目的的应用程序。
我正在使用 speakeasy生成认证的基础数据。它还可以吐出一个指向 Google 网站的 URL,生成一个 QR 码,我可以用 Google Authenticator 扫描它来设置方案。
我想自己生成二维码,主要是想在控制台使用qrcode-terminal显示出来.
我必须在 QR 码中编码哪些数据才能使其正常工作?
最佳答案
您必须编码的字符串是:
otpauth://totp/ApplicationName?secret= + key.base32
ApplicationName
是您希望在 Google 身份验证器中显示的应用程序的名称。
你的实现看起来像这样:
var key = speakeasy.generate_key( {length : 20} );
qrcode.generate( "otpauth://totp/foo?secret=" + key.base32, function( qrcode ) {
console.log( qrcode );
} );
还有 official documentation格式可用。
关于node.js - 我必须使用哪些数据才能为 Google Authenticator 生成二维码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21944544/