Hy!
I use google-mail-oauth2-tools but I have a problem:
When I write the verification code the program dead.
Traceback (most recent call last):
  File "oauth2.py", line 346, in <module>
    main(sys.argv)
  File "oauth2.py", line 315, in main
    print 'Refresh Token: %s' % response['refresh_token']
KeyError: 'refresh_token

Why?

Thank you!
You get this keyerror because there is no refresh_token in the response. If you didn't ask for offline access in your request, there will be no refresh token in the response, only an access token, bearer and token expiry.
google-mail-oauth2-tools KeyError :-/