It is quite simple but once it is done. Just go to your GMAIL account using web interface and look out for application specific password generation in you gmail security setting.
Step 2 of 2: Enter the generated application-specific password
You may now enter your new application-specific password into your application.Note that this password grants complete access to your Google Account. For security reasons, it will not be displayed again:
No need to memorise this password.
You should only need to enter it once. Spaces don’t matter.
Once the password generated must be entered as password to your iphone gmail account without spaces. now it is done