Photo Credit: AndroidPolice
Android currently has an SMS-based two-factor authentication (2FA) method for auto filling codes sent over SMS. The limitation with this method is that for it to work, developers have to code it in their apps. About a year ago, a Google Play Services update mentioned a new "verification code autofill" setting that, according to users, is finally rolling out. This means users are now able to autofill SMS 2FA codes from any app, whether or not the developers have coded the support for it in their apps or not.
According to a report by Android Police, the feature is currently not working for everybody and requires Google Messages version 5.5.096 and Google Play Services version 20.04.12, as dictated by the users who were able to get it running. The way it works is pretty simple but not very smart. When you click on the field to enter the code or OTP, you will get an option for “Autofill code from Messages”. Tap on it and it will show you a code and if that's the right code for you, click on it again which makes it appear in the field. The current drawback of this feature is that it only shows you the most recent code and that might not always be the correct one. Having said that, you will just need the most recent code most of the times.
If you have the aforementioned versions of Messages app and Google Play Services and want to enable this feature, you can go into Settings > Google > Verification code autofill and toggle the Autofill verification codes option. Bear in mind the option will be there even if the feature doesn't work. Another step involved in making this work is to make sure the autofill service is enabled. All autofill services regardless of it being a third-party one or Google's own service, the settings toggle should work.
The “Autofill code from Messages” is expected to roll out to more devices over the coming weeks and you can enable the toggle to see if it works for you. If not, you can still manually input your verification codes but that involves a few extra steps.