Get totp codes in Alfred in a secure way.
$ brew install oauthtool
Then insert your totp codes into the macOS keychain atotp.keychain
like so:
$ security -i
> create-keychain atotp.keychain
> set-keychain-settings atotp.keychain
> add-generic-password -a atotp -s "Name of service" -w "TOTP CODE" atotp.keychain
> # repeat above command as needed, crtl-c to quit.
Now download and install the worklow.
In alfred just type t
then start typing the name of your service.
The TOTP code will be pasted to the top most app by default and copied to the clipboard on option return.
On most websites you can login and see your totp code in the 2-factor setting page.
Thanks to aria.ia for the code on how to list items from macOS keychain.