'Android reading emails without enabling less secure app

So i came across this Less secure apps & your Google Account link, And it states that after the 30th of may this year, Enabling 'less secure apps' option will no longer be available.

enter image description here

I was wondering if there will be any alternative? I need to be able to read emails and download attachments through my application without the user having to do so himself, So the Gmail API is no good as far as i could see.

I also couldn't find any other option to access a gmail inbox without enabling this option... Ty for your time.



Solution 1:[1]

The whole point of this is that you should not be using someone's login and password to access gmail. You could try using an apps password but it is unlcear if this will work or not in the long run. Google has been very vague about that.

You should be authorizing the user either using Xoauth2 for the smtp server or by using the Gmail api and authorizing the user.

With oauth you can request a refresh token and then you will only need to request the users permission once after that you can use your refresh token to request a new access token.

Solution 2:[2]

The java mailer API works on password authentication(username and password). And if you want to use it with Gmail SMTP Server Address as the host you need to allow access less secure apps in your email account but this option is not available since may 30, this password authentication method will not work using gmail.

The option you can have is to use the gmail API to read/write to your gmail account another option is to use oauth2 to authenticate the account and save the tokens to the file so that you can use it to authenticate every time you call the api. For more on authorizing your app with google click here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DaImTo
Solution 2 Daudi Mabula