Skip to content

UnknownAPINameOrVersion Issue #197

Description

@Investigamer

For some reason PyDrive2 stopped authenticating in the latest release of my app even though I haven't changed ANYTHING about my PyDrive setup since last release. The weird thing is, authentication works absolutely fine running the app with Python in IDE, but as soon as I build as an exe with Pyinstaller, the exe version throws this error. The only change I can think of is I upgraded from Python 3.8 to 3.10.5. This is the error I'm getting:

File "proxyshop\core.py", line 385, in authenticate_user
   File "pydrive2\auth.py", line 136, in _decorated
   File "pydrive2\auth.py", line 626, in Auth
   File "pydrive2\auth.py", line 671, in Authorize
   File "googleapiclient\_helpers.py", line 130, in positional_wrapper
   File "googleapiclient\discovery.py", line 287, in build
   File "googleapiclient\discovery.py", line 404, in _retrieve_discovery_doc
 googleapiclient.errors.UnknownApiNameOrVersion: name: drive  version: v2

This is my yaml config:

client_config_backend: settings
client_config:
 client_id: *secret*
 client_secret: *secret*

save_credentials: True
save_credentials_backend: file
save_credentials_file: proxyshop/gauth.json

get_refresh_token: True
oauth_scope:
 - https://www.googleapis.com/auth/drive.readonly

This is the authentication setup:

def authenticate_user():
   """
   Create a GoogleDrive object using on-file gauth token or create
   a new one by getting permission from the user.
   @return: GoogleDrive object to use for downloads.
   """
   try:
       # Create gauth file if it doesn't exist yet
       if not os.path.exists(os.path.join(os.getcwd(), "proxyshop/gauth.json")):
           with open(os.path.join(os.getcwd(), "proxyshop/gauth.json"), 'w', encoding="utf-8") as fp:
               fp.write("")

       # Authenticate, fetch file and metadata
       auth = GoogleAuth(os.path.join(os.getcwd(), "proxyshop/gdrive.yaml"))
       auth.LocalWebserverAuth()
       return GoogleDrive(auth)

   except pydrive2.auth.AuthenticationRejected: return None
   except pydrive2.auth.AuthenticationError: return None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions