Finally managed to get round this today.
Goto the security option at https://myaccount.google.com
• Enable 2 factor authentication
• Once enabled there is a "App passwords" option on the 2FA page (https://myaccount.google.com/u/8/apppasswords)
• Create an app password for Apple Mail. It will then give you a 16 digit code to use in Apple Mail. (Note that if you copy and paste it will include the spaces between the blocks of 4 digits)
• Use this password in the IMAP/SMTP settings
After that, login to Gmail and goto the pop/imap settings
https://mail.google.com/mail/u/8/#settings/fwdandpop
• Enable IMAP here
Return to Apple Mail
• Sync you email and it should all work fine.