Search code examples
pythonmuttgmail-imap

Python syntax error when tryng to generate oauth2 token


I'm having a problem in running a command to get offlineimap running. I'm not an expert and don't code in python.

I need to run the following command:

python python/oauth2.py --generate_oauth2_token \
       --client_id=MY_CLIENT_ID --client_secret=MY_CLIENT_SECRET

And I'm using the following repository to access the oauth2.py: gmail-oauth2-tools.

The problem is that when running the command I'm getting the following syntax error in the .py file:

File "oauth2.py", line 297
print 'Missing options: %s' % ' '.join(missing)
                          ^
SyntaxError: invalid syntax

Below is the block of code where the error is contained:

    def RequireOptions(options, *args):
      missing = [arg for arg in args if getattr(options, arg) is None]
      if missing:
         print 'Missing options: %s' % ' '.join(missing)
         sys.exit(-1)

For more reference, what I'm trying to do is listed in this document: offlineimap.conf (line 946).


Solution

  • Had the same problem, running python2 python/oauth2.py instead of python python/oauth2.py fixed it for me (you need to have python2 installed on your system)