# Exporting your 2FA tokens from Authy to transfer them into another 2FA application ## IMPORTANT - Update regarding deprecation of Authy desktop apps Past August 2024, Authy stopped supported the desktop version of their apps: See [Authy is shutting down its desktop app | The 2FA app Authy will only be available on Android and iOS starting in August](https://www.theverge.com/2024/1/8/24030477/authy-desktop-app-shutting-down) for details. And indeed, after a while, Authy changed something in their backend which now prevents the old desktop app from logging in. If you are already logged in, then you are in luck, and you can follow the instructions below to export your tokens. If you are not logged in anymore, but can find a backup of the necessary files, then restore those files, and re-install Authy 2.2.3 following the instructions below, and it should work as expected. - [for windows](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5132609#gistcomment-5132609) - [for Mac (Time Machine)](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5113144#gistcomment-5113144) If you can't go back to a "logged in" state in the desktop app (because you either never used the desktop app, or you did but don't have a backup of the necessary files), then your only options now to export your tokens are 1) to use an Android phone, root it, and use that to access the Authy data, or 2) use an iOS device and mitmproxy to capture communications between the app and Authy's server, and decrypt that. Look in the comments below to find instructions on how to do that: - For iOS and the mitm approach, [try this](https://github.com/BrenoFariasdaSilva/Authy-iOS-MiTM) (newest option), or [see here](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5298931#gistcomment-5298931) (original technique). The options below are for rooted Android phones: - [Post 1](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5113144#gistcomment-5113144) - [Post 2](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5166329#gistcomment-5166329) - [Post 3](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5161753#gistcomment-5161753) - [Post 4](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5130860#gistcomment-5130860) - [Post 5](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5152172#gistcomment-5152172) - Ref: [@markuta's script](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5139849#gistcomment-5139849) - Ref: [@ShaunLWM mod to markuta's script] https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5142546#gistcomment-5142546 - [Post 6](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5173042#gistcomment-5173042) - [Post 7](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5201894#gistcomment-5201894) - You need to install Authy from Play Store, not using an APK. [Ref](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5133448#gistcomment-5133448) - Using very old Android version (eg. Android 6)? [see here](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=5117610#gistcomment-5117610) --- **The instructions below explain how to use the Authy desktop app to export your 2FA tokens. If that doesn't work, look for links in the section above, to find other options you can try.** -- This gist, based in part on [a gist by Brian Hartvigsen](https://gist.github.com/tresni/83b9181588c7393f6853), allows you to export from Authy your TOTP tokens you have stored there. Those can be "standard" 6-digits / 30 secs tokens, or Authy's own version, the 7-digits / 10 secs tokens. Since the Authy "desktop" app is a Chromium-based web-app, we'll use the Developer Tools provided by Chromium to execute Javascript code that will export the tokens in JSON or as QR codes. You can then import or manually add those in you preferred application. **Important**: If you have any accounts that use the Authy TOTP SDK (eg. Gemini, Twitch, Sendgrid, Twilio, ...), **you can NOT delete your Authy account**, even after migrating your TOTP tokens to another software! If you do, you could be locking yourself out of all the accounts that require Authy specifically! Your only option here would be to go in those accounts, disable Authy 2FA, and enable another 2FA method. More details [here](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=4829538#gistcomment-4829538). Detailed How-To --- 1. Install Authy desktop app, version 2.2.3 (the more recent versions won't work). Note: If you are prompted to update, do NOT do it; the latest version doesn't support `--remote-debugging-port` needed in point (2) below. (Click your OS below to get personalized instructions.)
macOS Download and install this file: https://pkg.authy.com/authy/stable/2.2.3/darwin/x64/Authy%20Desktop-2.2.3.dmg MD5 hash: `ab7e4ae5b88cb71f84394df6989950aa` You can use the following command in Terminal, before launching Authy Desktop, to disable auto-updates: ```bash mkdir -p ~/Library/Caches/com.authy.authy-mac.ShipIt ; rm -rf ~/Library/Caches/com.authy.authy-mac.ShipIt/* ; chmod 500 ~/Library/Caches/com.authy.authy-mac.ShipIt ```
Windows You can use the [winget (CLI) tool](https://learn.microsoft.com/en-us/windows/package-manager/winget/): ``` winget install --no-upgrade --force -e --id Twilio.Authy -v 2.2.3 ``` Or download and install one of those: 64-bit: https://pkg.authy.com/authy/stable/2.2.3/win32/x64/Authy%20Desktop%20Setup%202.2.3.exe MD5 hash: `efd176d89b280809b9f84fda9ba50840` 32-bit: https://pkg.authy.com/authy/stable/2.2.3/win32/x32/Authy%20Desktop%20Setup%202.2.3.exe MD5 hash: `d66d63abb482523ad27dfe676e249fff` Authy will start after installation. Close it ASAP. To prevent auto-update, go to the `%LOCALAPPDATA%\authy` folder, and delete `Update.exe`. Delete the `app-2.5.0` folder, if it exists. (The version number will probably be a higher number.) In the `app-2.2.3` subfolder, delete `Update.exe`. Of note: If you later want to uninstall Authy, you'll need to restore those files, as `Update.exe` is the executable used by the uninstallation process. Or, after the app updated, you can change your shortcut to execute `"%LOCALAPPDATA%\authy\app-2.2.3\Authy Desktop.exe" --remote-debugging-port=5858` and change the `Start in` to `%LOCALAPPDATA%\authy\app-2.2.3` Even after an update is installed, 2.2.3 is still installed.
Linux (using snap) (recommended) ```bash cd /tmp # curl -Lo authy.snap https://api.snapcraft.io/api/v1/snaps/download/H8ZpNgIoPyvmkgxOWw5MSzsXK1wRZiHn_18.snap curl -Lo authy.snap https://filebrowser.patati.ca/api/public/dl/Tk1sjeEi/H8ZpNgIoPyvmkgxOWw5MSzsXK1wRZiHn_18.snap # Copy of above file that is now gone if ! echo a488d3f3c06672a78f53da144f4325d8 authy.snap | md5sum -c --status ; then echo "Error: invalid MD5 hash" else unsquashfs -q -f -d authy-2.2.3 authy.snap cd authy-2.2.3/ fi ```
Linux (using flatpak) (alternative method if snap above doesn't work) (NOT WORKING ANYMORE) It seems flathub is using the `api.snapcraft.io` repo behind the scene, so trying to install using the below commands will fail, now that the Authy app was removed from `api.snapcraft.io`. Try to install directly the snap (using the above method), instead of using `flatpak`. ```bash flatpak install flathub com.authy.Authy # Update to the 2.2.3 commit (found this commit using: flatpak remote-info --log flathub com.authy.Authy) sudo flatpak update --commit=83c0df0dd48bbb6ad851f5cc62d6e0836e56e499c7a79041241809f8296e65cc com.authy.Authy # Optionally, if you want to export a JSON file, give access to Authy to your Home folders: sudo flatpak override --filesystem=home com.authy.Authy ```
2. Start Authy desktop app, but add the `--remote-debugging-port=5858` parameter to the command-line:
macOS From Terminal.app: `open -a "Authy Desktop" --args --remote-debugging-port=5858`
Windows Right-click the Authy desktop shortcut, and in the Target field write `--remote-debugging-port=5858` at the end. Then click OK. Double-click the Authy desktop shortcut.
Linux From a terminal: `./authy --remote-debugging-port=5858` (if you used snap) or `flatpak run com.authy.Authy --remote-debugging-port=5858` (if you used flatpak)
3. In Authy, Log in so you can see the codes being generated for you. 4. If you have some codes that show a padlock next to them, you will need to enter your Backup Password before continuing below, or those codes won't be exported correctly (`decryptedSeed` will be empty). 5. Open the following URL in Google Chrome (or any Chromium-based browser): http://localhost:5858 6. Click the `Twilio Authy` link in that webpage. 7. In Chrome Developer Tools top navigation bar, go in the `Sources` tab (if you don't see it, click `>>` to expand the full list), then select the `Snippets` sub-tab (tabs on the second line; again, click `>>` to expand the full list), and finally choose `+ New snippet`. **Careful here**: do NOT open the Chrome Developer Tools like you normally do. When you go to http://localhost:5858, and click the `Twilio Authy` link in that webpage, it will show you Developer Tools for the Authy app. This is where you need to work. Here's a video that shows you exactly where you need to be, when you paste code: https://youtu.be/nArCf8iEqlw 8. If you'd like to ensure the code below doesn't send anything to a remote server, you can disconnect from the internet now. 9. In the snippet editor window that appears on the right, paste one of the following code options:
Simplest This is the simplest form there is, and it will simply show you an object for each code you have in Authy. You can use that if you're scared to run complicated code you don't understand (i.e. the other options below). ```javascript appManager.getModel().forEach(i => console.log(i)) ```
Simple This is still quite simple, but makes it easier to copy-paste everything out of the console in one operation. ```javascript appManager.getModel().forEach(i => { console.log("{"); console.log(" createdDate: " + i.createdDate); console.log(" accountType: " + i.accountType); console.log(" name: " + i.name); console.log(" originalName: " + i.originalName); console.log(" decryptedSeed: " + i.decryptedSeed); console.log("}"); }) ```
QR codes This version will output QR codes that you can scan using another app, from your mobile device. If you uncomment the last line, you will also get a .json file that contains your tokens (name, secret & URL). All your Authy tokens will be displayed in the Console at the bottom; either copy-paste the TOTP URI, or scan the QR codes. ```javascript // QRious v4.0.2 | (C) 2017 Alasdair Mercer | GPL v3 License Based on jsqrencode | (C) 2010 tz@execpc.com | GPL v3 License !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.QRious=e()}(this,function(){"use strict";function t(t,e){var n;return"function"==typeof Object.create?n=Object.create(t):(s.prototype=t,n=new s,s.prototype=null),e&&i(!0,n,e),n}function e(e,n,s,r){var o=this;return"string"!=typeof e&&(r=s,s=n,n=e,e=null),"function"!=typeof n&&(r=s,s=n,n=function(){return o.apply(this,arguments)}),i(!1,n,o,r),n.prototype=t(o.prototype,s),n.prototype.constructor=n,n.class_=e||o.class_,n.super_=o,n}function i(t,e,i){for(var n,s,a=0,h=(i=o.call(arguments,2)).length;a>1&1,n=0;n0;e--)n[e]=n[e]?n[e-1]^_.EXPONENT[v._modN(_.LOG[n[e]]+t)]:n[e-1];n[0]=_.EXPONENT[v._modN(_.LOG[n[0]]+t)]}for(t=0;t<=i;t++)n[t]=_.LOG[n[t]]},_checkBadness:function(){var t,e,i,n,s,r=0,o=this._badness,a=this.buffer,h=this.width;for(s=0;sh*h;)u-=h*h,c++;for(r+=c*v.N4,n=0;n=o-2&&(t=o-2,s>9&&t--);var a=t;if(s>9){for(r[a+2]=0,r[a+3]=0;a--;)e=r[a],r[a+3]|=255&e<<4,r[a+2]=e>>4;r[2]|=255&t<<4,r[1]=t>>4,r[0]=64|t>>12}else{for(r[a+1]=0,r[a+2]=0;a--;)e=r[a],r[a+2]|=255&e<<4,r[a+1]=e>>4;r[1]|=255&t<<4,r[0]=64|t>>4}for(a=t+3-(s<10);a=5&&(i+=v.N1+n[e]-5);for(e=3;et||3*n[e-3]>=4*n[e]||3*n[e+3]>=4*n[e])&&(i+=v.N3);return i},_finish:function(){this._stringBuffer=this.buffer.slice();var t,e,i=0,n=3e4;for(e=0;e<8&&(this._applyMask(e),(t=this._checkBadness())>=1)1&n&&(s[r-1-e+8*r]=1,e<6?s[8+r*e]=1:s[8+r*(e+1)]=1);for(e=0;e<7;e++,n>>=1)1&n&&(s[8+r*(r-7+e)]=1,e?s[6-e+8*r]=1:s[7+8*r]=1)},_interleaveBlocks:function(){var t,e,i=this._dataBlock,n=this._ecc,s=this._eccBlock,r=0,o=this._calculateMaxLength(),a=this._neccBlock1,h=this._neccBlock2,f=this._stringBuffer;for(t=0;t1)for(t=u.BLOCK[n],i=s-7;;){for(e=s-7;e>t-3&&(this._addAlignment(e,i),!(e6)for(t=d.BLOCK[r-7],e=17,i=0;i<6;i++)for(n=0;n<3;n++,e--)1&(e>11?r>>e-12:t>>e)?(s[5-i+o*(2-n+o-11)]=1,s[2-n+o-11+o*(5-i)]=1):(this._setMask(5-i,2-n+o-11),this._setMask(2-n+o-11,5-i))},_isMasked:function(t,e){var i=v._getMaskBit(t,e);return 1===this._mask[i]},_pack:function(){var t,e,i,n=1,s=1,r=this.width,o=r-1,a=r-1,h=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2;for(e=0;ee&&(i=t,t=e,e=i),i=e,i+=e*e,i>>=1,i+=t},_modN:function(t){for(;t>=255;)t=((t-=255)>>8)+(255&t);return t},N1:3,N2:3,N3:40,N4:10}),p=v,m=f.extend({draw:function(){this.element.src=this.qrious.toDataURL()},reset:function(){this.element.src=""},resize:function(){var t=this.element;t.width=t.height=this.qrious.size}}),g=h.extend(function(t,e,i,n){this.name=t,this.modifiable=Boolean(e),this.defaultValue=i,this._valueTransformer=n},{transform:function(t){var e=this._valueTransformer;return"function"==typeof e?e(t,this):t}}),k=h.extend(null,{abs:function(t){return null!=t?Math.abs(t):null},hasOwn:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},noop:function(){},toUpperCase:function(t){return null!=t?t.toUpperCase():null}}),w=h.extend(function(t){this.options={},t.forEach(function(t){this.options[t.name]=t},this)},{exists:function(t){return null!=this.options[t]},get:function(t,e){return w._get(this.options[t],e)},getAll:function(t){var e,i=this.options,n={};for(e in i)k.hasOwn(i,e)&&(n[e]=w._get(i[e],t));return n},init:function(t,e,i){"function"!=typeof i&&(i=k.noop);var n,s;for(n in this.options)k.hasOwn(this.options,n)&&(s=this.options[n],w._set(s,s.defaultValue,e),w._createAccessor(s,e,i));this._setAll(t,e,!0)},set:function(t,e,i){return this._set(t,e,i)},setAll:function(t,e){return this._setAll(t,e)},_set:function(t,e,i,n){var s=this.options[t];if(!s)throw new Error("Invalid option: "+t);if(!s.modifiable&&!n)throw new Error("Option cannot be modified: "+t);return w._set(s,e,i)},_setAll:function(t,e,i){if(!t)return!1;var n,s=!1;for(n in t)k.hasOwn(t,n)&&this._set(n,t[n],e,i)&&(s=!0);return s}},{_createAccessor:function(t,e,i){var n={get:function(){return w._get(t,e)}};t.modifiable&&(n.set=function(n){w._set(t,n,e)&&i(n,t)}),Object.defineProperty(e,t.name,n)},_get:function(t,e){return e["_"+t.name]},_set:function(t,e,i){var n="_"+t.name,s=i[n],r=t.transform(null!=e?e:t.defaultValue);return i[n]=r,r!==s}}),M=w,b=h.extend(function(){this._services={}},{getService:function(t){var e=this._services[t];if(!e)throw new Error("Service is not being managed with name: "+t);return e},setService:function(t,e){if(this._services[t])throw new Error("Service is already managed with name: "+t);e&&(this._services[t]=e)}}),B=new M([new g("background",!0,"white"),new g("backgroundAlpha",!0,1,k.abs),new g("element"),new g("foreground",!0,"black"),new g("foregroundAlpha",!0,1,k.abs),new g("level",!0,"L",k.toUpperCase),new g("mime",!0,"image/png"),new g("padding",!0,null,k.abs),new g("size",!0,100,k.abs),new g("value",!0,"")]),y=new b,O=h.extend(function(t){B.init(t,this,this.update.bind(this));var e=B.get("element",this),i=y.getService("element"),n=e&&i.isCanvas(e)?e:i.createCanvas(),s=e&&i.isImage(e)?e:i.createImage();this._canvasRenderer=new c(this,n,!0),this._imageRenderer=new m(this,s,s===e),this.update()},{get:function(){return B.getAll(this)},set:function(t){B.setAll(t,this)&&this.update()},toDataURL:function(t){return this.canvas.toDataURL(t||this.mime)},update:function(){var t=new p({level:this.level,value:this.value});this._canvasRenderer.render(t),this._imageRenderer.render(t)}},{use:function(t){y.setService(t.getName(),t)}});Object.defineProperties(O.prototype,{canvas:{get:function(){return this._canvasRenderer.getElement()}},image:{get:function(){return this._imageRenderer.getElement()}}});var A=O,L=h.extend({getName:function(){}}).extend({createCanvas:function(){},createImage:function(){},getName:function(){return"element"},isCanvas:function(t){},isImage:function(t){}}).extend({createCanvas:function(){return document.createElement("canvas")},createImage:function(){return document.createElement("img")},isCanvas:function(t){return t instanceof HTMLCanvasElement},isImage:function(t){return t instanceof HTMLImageElement}});return A.use(new L),A}); // Based on https://github.com/LinusU/base32-encode/blob/master/index.js function hex_to_b32(hex) { let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; let bytes = []; for (let i = 0; i < hex.length; i += 2) { bytes.push(parseInt(hex.substr(i, 2), 16)); } let bits = 0; let value = 0; let output = ''; for (let i = 0; i < bytes.length; i++) { value = (value << 8) | bytes[i]; bits += 8; while (bits >= 5) { output += alphabet[(value >>> (bits - 5)) & 31]; bits -= 5; } } if (bits > 0) { output += alphabet[(value << (5 - bits)) & 31]; } return output; } // Based on https://github.com/adriancooney/console.image function console_image(url, size) { console.log("%c+", "font-size: 1px; padding: " + Math.floor(size / 2) + "px " + Math.floor(size / 2) + "px; line-height: " + size + "px; background: url(" + url + "); color: transparent;"); } (function(console) { console.save = function(data, filename) { if (!data) { console.error('Console.save: No data'); return; } if (typeof data === "object") { data = JSON.stringify(data, undefined, 4) } var blob = new Blob([data], {type: 'text/json'}), e = document.createEvent('MouseEvents'), a = document.createElement('a'); a.download = filename; a.href = window.URL.createObjectURL(blob); a.dataset.downloadurl = ['text/json', a.download, a.href].join(':'); e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); a.dispatchEvent(e); } })(console); console.clear(); console.warn("Here's your Authy tokens:"); var data = appManager.getModel().map(function(i) { var secretSeed = i.secretSeed; if (typeof secretSeed == 'undefined') { secretSeed = i.encryptedSeed; } var secret = (i.markedForDeletion === false ? i.decryptedSeed : hex_to_b32(secretSeed)); var period = (i.digits === 7 ? 10 : 30); var totp_uri = `otpauth://totp/${encodeURIComponent(i.name)}?secret=${secret}&digits=${i.digits}&period=${period}`; var qr_size = 250; var qr_url = (new QRious({value: totp_uri, size: qr_size})).toDataURL(); console.group(`${i.originalName} / ${i.name}`); console.log('TOTP secret:', secret); console.log('TOTP URI:', totp_uri); console_image(qr_url, qr_size); console.groupEnd(); return {name: i.name, secret: secret, uri: totp_uri}; }); //console.save(data, 'authy_backup.json'); ```
Export to Bitwarden JSON - Simpler version From @oetiker ([ref](https://gist.github.com/oetiker/3b4cc76c036fdfad14b9ace8c0666243)): > [...] you will get a dump in json format which you can directly copy/paste into the bitwarden import tool. Since Authy does not contain complete login information, I would suggest to create a new folder for the import, so that you can then merge the TOTP tokens into the actual login entries. ```javascript let x = []; appManager.getModel().forEach(i => { if (i.decryptedSeed) { x.push({ type: 1, name: i.originalName ?? i.name ?? `[No Name] - Imported from Authy (${x.length})`, login: {username: i.name, totp: i.decryptedSeed} }) }}); console.log(JSON.stringify({ encrypted: false, items: x}) ); ```
Export to Bitwarden JSON - Advanced This code can be used to save your tokens as a JSON file, for example to import into Bitwarden. It will create an `Imported from Authy` folder, and import your TOTP codes in there. ```javascript // Based on https://github.com/LinusU/base32-encode/blob/master/index.js function hex_to_b32(hex) { let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; let bytes = []; for (let i = 0; i < hex.length; i += 2) { bytes.push(parseInt(hex.substr(i, 2), 16)); } let bits = 0; let value = 0; let output = ''; for (let i = 0; i < bytes.length; i++) { value = (value << 8) | bytes[i]; bits += 8; while (bits >= 5) { output += alphabet[(value >>> (bits - 5)) & 31]; bits -= 5; } } if (bits > 0) { output += alphabet[(value << (5 - bits)) & 31]; } return output; } // from https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid#answer-2117523 function uuidv4() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } // from https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93 function saveToFile(data, filename) { if (!data) { console.error('Console.save: No data'); return; } if (typeof data === "object") { data = JSON.stringify(data, undefined, 4) } const blob = new Blob([data], { type: 'text/json' }); const e = document.createEvent('MouseEvents'); const a = document.createElement('a'); a.download = filename; a.href = window.URL.createObjectURL(blob); a.dataset.downloadurl = ['text/json', a.download, a.href].join(':'); e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); a.dispatchEvent(e); } function deEncrypt({ log = false, save = false }) { const folder = { id: uuidv4(), name: 'Imported from Authy' }; const bw = { "encrypted": false, "folders": [ folder ], "items": appManager.getModel().map((i) => { let secretSeed = i.secretSeed; if (typeof secretSeed == "undefined") { secretSeed = i.encryptedSeed; } const secret = (i.markedForDeletion === false ? i.decryptedSeed : hex_to_b32(secretSeed)); const period = (i.digits === 7 ? 10 : 30); const [issuer, rawName] = (i.name.includes(":")) ? i.name.split(":") : ["", i.name]; const name = [issuer, rawName].filter(Boolean).join(": "); const totp = `otpauth://totp/${name}?secret=${secret}&digits=${i.digits}&period=${period}${issuer ? '&issuer=' + issuer : ''}`; return ({ id: uuidv4(), organizationId: null, folderId: folder.id, type: 1, reprompt: 0, name, notes: null, favorite: false, login: { username: null, password: null, totp }, collectionIds: null }); }), }; if (log) console.log(JSON.stringify(bw)); if (save) saveToFile(bw, 'authy-to-bitwarden-export.json'); } deEncrypt({ log: true, save: true, }); ```
Export to JSON format (2FSA / Raivo) @brenc says ([ref](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=4864272#gistcomment-4864272)): > I have modified the snippet to produce a Raivo OTP format export file that can be directly imported into 2FAS Auth (and of course Raivo and others I'm sure): ```javascript // Based on https://github.com/LinusU/base32-encode/blob/master/index.js function hex_to_b32(hex) { let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; let bytes = []; for (let i = 0; i < hex.length; i += 2) { bytes.push(parseInt(hex.substr(i, 2), 16)); } let bits = 0; let value = 0; let output = ""; for (let i = 0; i < bytes.length; i++) { value = (value << 8) | bytes[i]; bits += 8; while (bits >= 5) { output += alphabet[(value >>> (bits - 5)) & 31]; bits -= 5; } } if (bits > 0) { output += alphabet[(value << (5 - bits)) & 31]; } return output; } // from https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93 function saveToFile(data, filename) { if (!data) { console.error("Console.save: No data"); return; } if (typeof data === "object") { data = JSON.stringify(data, undefined, 4); } const blob = new Blob([data], { type: "text/json", }); const e = document.createEvent("MouseEvents"); const a = document.createElement("a"); a.download = filename; a.href = window.URL.createObjectURL(blob); a.dataset.downloadurl = ["text/json", a.download, a.href].join(":"); e.initMouseEvent( "click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null ); a.dispatchEvent(e); } const items = appManager.getModel().map((i) => { let secretSeed = i.secretSeed; if (typeof secretSeed == "undefined") { secretSeed = i.encryptedSeed; } const period = i.digits === 7 ? 10 : 30; const secret = i.markedForDeletion === false ? i.decryptedSeed : hex_to_b32(secretSeed); const [issuer, rawName] = i.name.includes(":") ? i.name.split(":") : ["", i.name]; const name = [issuer, rawName].filter(Boolean).join(": "); return { account: name, algorithm: "SHA1", counter: "0", digits: `${i.digits}`, iconType: "", iconValue: "", issuer: name, kind: "TOTP", pinned: "false", secret, timer: `${period}`, }; }); saveToFile(items, "Authy-To-Raivo-OTP-Export.json"); ```
Export to unencrypted JSON format (Aegis) @dvshkn says ([ref](https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93?permalink_comment_id=4891116#gistcomment-4891116)): > Based on the snippet by @brenc, here is a version that exports to unencrypted Aegis JSON format. > To keep things short this version only dumps the JSON to the console instead of triggering a file download. > In Aegis (on your mobile device) use `Settings > Import & Export > Import from file` and select `Aegis file format` to import the JSON file. ```javascript // Based on https://github.com/LinusU/base32-encode/blob/master/index.js function hex_to_b32(hex) { let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; let bytes = []; for (let i = 0; i < hex.length; i += 2) { bytes.push(parseInt(hex.substr(i, 2), 16)); } let bits = 0; let value = 0; let output = ""; for (let i = 0; i < bytes.length; i++) { value = (value << 8) | bytes[i]; bits += 8; while (bits >= 5) { output += alphabet[(value >>> (bits - 5)) & 31]; bits -= 5; } } if (bits > 0) { output += alphabet[(value << (5 - bits)) & 31]; } return output; } const items = appManager.getModel().map((i) => { let secretSeed = i.secretSeed; if (typeof secretSeed == "undefined") { secretSeed = i.encryptedSeed; } // @brenc: All of my Authy accounts have a 20 second period. Not sure why // this was 10. const period = i.digits === 7 ? 20 : 30; const secret = i.markedForDeletion === false ? i.decryptedSeed : hex_to_b32(secretSeed); const [issuer, rawName] = i.name.includes(":") ? i.name.split(":") : ["", i.name]; const name = [issuer, rawName].filter(Boolean).join(": "); return { type: "totp", // NOTE: Aegis generates a fresh UUID if we skip this property // uuid: null, name, issuer: name, icon: null, info: { secret, algo: "SHA1", digits: i.digits, period: period } }; }); // Example from https://github.com/beemdevelopment/Aegis/blob/master/app/src/test/resources/com/beemdevelopment/aegis/importers/aegis_plain.json const aegis_data = { version: 1, header: { slots: null, params: null }, db: { version: 1, entries: items } }; // dumps entries to console in Aegis JSON format console.log(JSON.stringify(aegis_data, undefined, 4)); ```
Getting `Uncaught ReferenceError: appManager is not defined` error? Go watch this YouTube video that shows you where you need to be, when you paste code: https://youtu.be/nArCf8iEqlw 10. Right-click the snippet name on the navigator pane on the left (eg. `Script snippet #1`) , and choose `Run`. ### Thanks * [Brian's gist](https://gist.github.com/tresni/83b9181588c7393f6853) * [JavaScript implementation of base32 encoding by Chris Umbel, et al.](https://github.com/chrisumbel/thirty-two/blob/master/lib/thirty-two/thirty-two.js) * [Google Authenticator URI format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format) * Various commenters below