0

I need to search through all of someone's emails for a compliance exercise. The individual has one gmail account that he forwards all of his other accounts to. However, I get an authentication error when I try to access the umbrella account, despite the fact that I can login to the umbrella account through the browser. See specific questions after description.

This fails - note the domain name isn't gmail.com - it's user@usersfullname.com but I access it via the browser by logging into gmail.com

import imaplib
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login(user@usersname.com, password)

I get an authentication error ("Invalid credentials (Failure) despite the fact that the same credentials let me login on the browser. I unlocked the account etc. using these instructions: https://om4.com.au/google-apps-gmail-invalid-credentials-unlock-captcha/

I CAN login to one of the accounts that's being forwarded to the umbrella account which DOES have an @gmail.com domain name with exactly the same credentials i.e.:

mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login(user@gmail.com, same_password_as_above)

Questions:

(1) Is it possible that the reason I'm getting an authentication failure that I'm using the wrong imap information - the login to the gmail account is @username.com, not gmail.com. If so, how do I figure out what the right stmp server is? It doesn't say in the Gmail Settings - Accounts & Import tab (Note: the password and username are definitely correct)

(2) Is there another reason that I could be getting an authentication error? Note that I unlocked the account - see above and my script is working for other gmail accounts...

kalidurge
  • 279
  • 2
  • 11
  • 1
    Gmail generally blocks IMAP logins that don't use OAuth by default, especially for gsuite activations. If you or the admin can turn on Less Secure Apps, or generate an App Specific Password, you may be able to get around having to use OAuth. – Max Jun 03 '19 at 18:07
  • @Max true...I feel like I knew that already. Yup, that totally works. Thanks – kalidurge Jun 04 '19 at 13:06
  • You may want to self-answer if you found a solution that works for you. – Max Jun 05 '19 at 15:08

1 Answers1

0

Here's how I solved my problem:

Step 1) Sign in to the administrator account and follow these instructions to allow the other sub-accounts to change access to less secure apps: https://support.google.com/a/answer/6260879

Step 2) Go to specific gmail account you need to access and follow these instructions to allow access for less secure apps: https://support.google.com/accounts/answer/6010255?hl=en

Step 3) I also followed these instructions (https://om4.com.au/google-apps-gmail-invalid-credentials-unlock-captcha/ but I'm not sure it was necessary

kalidurge
  • 279
  • 2
  • 11