googleapis / google-api-python-client

🐍 The official Python client library for Google's discovery based APIs.
https://googleapis.github.io/google-api-python-client/docs/
Apache License 2.0
7.67k stars 2.4k forks source link

drive.About documentation wrong/missing #1742

Open FirefighterBlu3 opened 2 years ago

FirefighterBlu3 commented 2 years ago

Environment details

Steps to reproduce

  1. .# setup creds (a service account)
  2. service = build('drive', 'v3', credentials=creds)
  3. service.about().get().execute()

Code example

# setup creds (a service account)
service = build('drive', 'v3', credentials=creds)
service.about().get().execute()

Stack trace

  File "/home/david/Desktop/Projects/indeed/gdrive-revisions/gdrive_revisions.py", line 36, in get_drive
    data = service.about().get().execute()
  File "/usr/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 131, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/googleapiclient/http.py", line 937, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/drive/v3/about?alt=json returned "The 'fields' parameter is required for this method.". Details: "[{'message': "The 'fields' parameter is required for this method.", 'domain': 'global', 'reason': 'required', 'location': 'fields', 'locationType': 'parameter'}]">

The docstring for this method indicates there are no explicit calling arguments:

method(**kwargs) method of googleapiclient.discovery.Resource instance
    Gets information about the user, the user's Drive, and system capabilities.

    Args:
    ...

Additionally, the documentation at https://developers.google.com/resources/api-libraries/documentation/drive/v3/python/latest/drive_v3.about.html also indicates there are no consumed arguments

parthea commented 2 years ago

Hi @FirefighterBlu3,

Thanks for reporting an issue with the docs. I can confirm that the fields parameter is needed for service.about().get(). I'll keep this issue open until the docs are fixed.

The following code worked to get information about the current user:

service.about().get(fields="user").execute()

You can also use * during development to get all fields as described here. For example,

service.about().get(fields="*").execute()

You'll achieve greater performance by only selecting the fields you need.