Skip to content
This repository was archived by the owner on Jul 22, 2021. It is now read-only.
This repository was archived by the owner on Jul 22, 2021. It is now read-only.

Authenticating Service Accounts #107

@Joehutz

Description

@Joehutz

Hi,

I'm trying to build an application and hope to use service account credentials for uploading and downloading. I'm having some issues authenticating the service account by following PyDrive's documentation.

After creating my service account, I renamed the "secret" to 'client_secrets.json' and I encounter the following error message when I authenticate:

Traceback (most recent call last):
  File "downloader.py", line 24, in <module>
    file_list = drive.ListFile().GetList()
  File "C:\Python36-32\lib\site-packages\pydrive-1.3.1-py3.6.egg\pydrive\apiattr.py", line 162, in GetList
  File "C:\Python36-32\lib\site-packages\pydrive-1.3.1-py3.6.egg\pydrive\apiattr.py", line 146, in __next__
  File "C:\Python36-32\lib\site-packages\pydrive-1.3.1-py3.6.egg\pydrive\auth.py", line 57, in _decorated
  File "C:\Python36-32\lib\site-packages\pydrive-1.3.1-py3.6.egg\pydrive\auth.py", line 113, in _decorated
  File "C:\Python36-32\lib\site-packages\pydrive-1.3.1-py3.6.egg\pydrive\auth.py", line 443, in GetFlow
  File "C:\Python36-32\lib\site-packages\pydrive-1.3.1-py3.6.egg\pydrive\auth.py", line 366, in LoadClientConfig
  File "C:\Python36-32\lib\site-packages\pydrive-1.3.1-py3.6.egg\pydrive\auth.py", line 388, in LoadClientConfigFile
pydrive.settings.InvalidConfigError: Invalid client secrets file Invalid file format. See https://developers.google.com/api-client-library/python/guide/aaa_client_secrets Expected a JSON object with a single property for a "web" or "installed" application

When I look at auth.py, I see the function defined as ServiceAuth().
I'm able to use google's stock api to achieve listfile:

scopes = ['https://www.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name('client_secrets.json', scopes)
http_auth = credentials.authorize(Http())
drive = build('drive','v3',http=http_auth)

response = drive.files().list().execute()

How do I go about authenticating a service account via PyDrive?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions