Here’s a very simple solution I found to log in to my X.com account from a VM in Qubes OS.
On your smartphone, open a web browser and go to https://x.com.
Log in with your Google account.
Click “Settings & privacy” > Security & account access > Security > 2-factor authentication > Backup codes > Your code will be displayed and is also called a “backup code”. On your virtual machine, which has an internet connection, log in to your X account with your Google email address. A message will ask you to enter your verification code. Do not enter anything. Click on “Use another method” > “Select an authentication method. You then have two choices:
Choice 1: Authenticator app
Choice 2: Backup code
You must use a virtual machine with an internet connection, and if you are using a VPN with your web browser, you must temporarily disable the VPN.
Choose backup code. Enter your code.
Please note that X uses a random code generator.
Each time you click on “Choice 2: Backup code,” the code changes!
Once you are logged into your X account, you can reactivate the VPN.