In a browser, go to your Google Account and
select Manage your Google Account
Select the Security tab. Turn on 2-Step Verification (which generates a new section, App Passwords).
Then tap App Passwords
Select Mail and iPhone from the drop menus and then click Generate. This is the password you will use in the app to sign into your Gmail account. When you are signing in for the mail sync service, this would be entered in the IMAP email login option.