Service Account and PyDrive

I would like to use the Google Drive API to store some backups on it using cronjob. I just don't understand how I can use PyDrive with a service account. When I create a service account file and I put it in a directory as my script like client_secret.json.

Using this code:

#!/usr/bin/env python
# -*- coding: utf8 -*-


from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

def main():

    gauth = GoogleAuth()
    drive = GoogleDrive(gauth)

    f = drive.CreateFile({'parent': 'toto'})
    f.SetContentFile('test.drive.py')
    f.Upload()

if __name__ == '__main__':
    main(sys.argv[1:])

Result

pydrive.settings.InvalidConfigError: Invalid client secrets file Invalid file format.

Good. Then I look at other posts on SO and find these two:
Automating the verification process
The code from the first answer on this question returns the following:

Traceback (most recent call last):
  File "test.drive.py", line 4, in <module>
    from oauth2client.client import SignedJwtAssertionCredentials
ImportError: cannot import name SignedJwtAssertionCredentials

And this one:
Automating the pydrive verification process
Which is just ... It doesn't help me much.

Where to begin? What should I do? Can someone give me an example with pydrive and Service Authentication just to download a file?

EDIT:
, pycrypto, , . , , .

+4
1

, pycrypto , . , , .

0

All Articles