Gmail authentication error on less secure apps

Integrating Google login in the mobile apps, web apps is a trend! To follow this trend, keeping up with everyday advancing Google’s settings is itself a challenge especially if you are using a third party open source library which uses Google login in it.
In the past, I worked on open source K9 mail app to create custom mail app. It allows users to do gmail login. Recently, K9 app started giving me an authentication error even after entering correct gmail credentials.

Googling itself helped me to figure out the solution. It is because a change in the process of using Google authentication within your own app. Most of the apps recently started throwing the same exception as Google marked these apps as a less secure app including Outlook mail app (Ref. Because these apps might be still using an old process of doing Google login.
The best way to get out of this issue is updating your apps, open source libraries with latest Google authentication process. But there is always a workaround to fix something temporarily. So here is the quickest hack-

Hope this simple hack saves someone’s time!!