I'm not sure if anyone else already mentioned this but it's the only thing it worked for me. This requires you can still login through other methods on the microsoft website, since in my case, i didn't get a verification code when it was "sent" through windows/xbox app/microsoft store.
- Go to your Microsoft Account on the browser
- Go to Security -> Manage logins
3- Add a new login method or verification
4- Select "Use an application". This are authentication apps, probably the safest option to have on your account.
After step 4 just follow the instructions it gives you, and next time you try to login, it will ask for the code in the authentication app instead. It will recommend using the Microsft Auth app, but you could use any other if you know about it.
Remember that if you do this, and want to change your phone later, you'll need to probably migrate the app to the new device, just investigate what you need to do after.