1

I am following the instruction to use PyDrive on this documentation link and after running this part

from pydrive.auth import GoogleAuth

gauth = GoogleAuth()
gauth.LocalWebserverAuth() # Creates local webserver and auto handles authentication.

everything seems to work fine, my browser opens and I need to authenticate with my Gmail account. But after accepting the last part the process loads and I get an error message in the browser Safari Screenshot it's German and it basically says that safari wasn't able to connect to localhost:8080.

In the terminal I get this Traceback:

Failed to find "code" in the query parameters of the redirect.
Try command-line authentication
Traceback (most recent call last):
  File "/Users/gepluse/CodeProjects/ComunioBuster/test2.py", line 4, in <module>
    gauth.LocalWebserverAuth()  # Creates local webserver and auto handles authentication.
  File "/Users/gepluse/CodeProjects/ComunioBuster/venv/lib/python3.8/site-packages/pydrive/auth.py", line 115, in _decorated
    code = decoratee(self, *args, **kwargs)
  File "/Users/gepluse/CodeProjects/ComunioBuster/venv/lib/python3.8/site-packages/pydrive/auth.py", line 241, in LocalWebserverAuth
    raise AuthenticationError('No code found in redirect')
pydrive.auth.AuthenticationError: No code found in redirect

I also followed this tutorial link and I checked every step I made several times without any success.

In some posts here the firewall was the issue but the firewall on my Mac isn't activated.

I'm running macOS 10.15.7 / Python 3.8.3 / PyDrive 1.3.1

mrivanlima
  • 561
  • 4
  • 10
GePlusE
  • 13
  • 10

1 Answers1

0

I made changes according to this Solution by Dano. The save and load of mycreds.txt helped to solve this issue.

GePlusE
  • 13
  • 10
  • I am having this issue as well but I'm not able to solve it. Are you saying you were able to solve it with adding this step: ``` gauth.LoadCredentialsFile("mycreds.txt") if gauth.credentials is None: # Authenticate if they're not there gauth.LocalWebserverAuth() elif gauth.access_token_expired: # Refresh them if expired gauth.Refresh() else: # Initialize the saved creds gauth.Authorize() # Save the current credentials to a file gauth.SaveCredentialsFile("mycreds.txt") ```? – doij790 Mar 15 '22 at 18:34