Authentication Issue: UnicodeDecodeError
Opened this issue · 0 comments
i-bond commented
Hello, everyone! I was following the quickstart guide on PyDrive, downloaded client_secret_.json. file, renamed it and encountered the following issue:
from pydrive.auth import GoogleAuth
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 0: invalid continuation byte
Tried to change encoding to latin-1:
import codecs
BLOCKSIZE = 1048576 # or some other, desired size in bytes
with codecs.open(source_path, "r", "utf-8") as sourceFile:
with codecs.open('client_secrets.json', "w", "latin-1") as targetFile:
while True:
contents = sourceFile.read(BLOCKSIZE)
if not contents:
break
targetFile.write(contents)
But after this it throws another error:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Could you help me to find out what causes these errors and how to properly authenticate with PyDrive?