Error: IMAP: [ALERT] Web login required (Failure)

What is the resolution to the above problem? Should I be logged in to the gmail account or not. Although it happens whether I'm logged in or not.

Imap error message

cannot access email/gmail as it says web login required