~aaron-whitehouse/duplicity/08-python-futurize-stage-1

« back to all changes in this revision

Viewing changes to duplicity/backends/pydrivebackend.py

  • Committer: Kenneth Loafman
  • Date: 2016-11-01 14:08:20 UTC
  • Revision ID: kenneth@loafman.com-20161101140820-4a9ogywpg1eg7cmv
* Fixed bug #1621194 with code from Tornhoof
  - Do backup to google drive working without a service account

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        elif 'GOOGLE_DRIVE_SETTINGS' in os.environ:
67
67
            gauth = GoogleAuth(settings_file=os.environ['GOOGLE_DRIVE_SETTINGS'])
68
68
            gauth.CommandLineAuth()
 
69
        elif ('GOOGLE_SECRETS_FILE' in os.environ and 'GOOGLE_CREDENTIALS_FILE' in os.environ):
 
70
            gauth = GoogleAuth()
 
71
            gauth.LoadClientConfigFile(os.environ['GOOGLE_SECRETS_FILE'])
 
72
            gauth.LoadCredentialsFile(os.environ['GOOGLE_CREDENTIALS_FILE'])
 
73
            if gauth.credentials is None:
 
74
                gauth.CommandLineAuth()
 
75
            elif gauth.access_token_expired:
 
76
                gauth.Refresh()
 
77
            else:
 
78
                gauth.Authorize()
 
79
            gauth.SaveCredentialsFile(os.environ['GOOGLE_CREDENTIALS_FILE'])
69
80
        else:
70
81
            raise BackendException(
71
82
                'GOOGLE_DRIVE_ACCOUNT_KEY or GOOGLE_DRIVE_SETTINGS environment '