A
A
Andrey Kalashnik2021-11-09 12:00:14
Python
Andrey Kalashnik, 2021-11-09 12:00:14

How to replace ServiceAccountCredentials?

There is a Python code:

from oauth2client.service_account import ServiceAccountCredentials

Scopes = [ "https://spreadsheets.google.com/feeds", 'https://www.googleapis.com/auth/spreadsheets', "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive" ]
Creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", Scopes)
Client = gspread.authorize(Creds)
Sheet = Client.open("lol2280").sheet1
Data = Sheet.get_all_records()


This is needed to interact with GoogleSheets. But I have a problem with the ServiceAccountCredentials library when translating Python to C and compiling to .exe using Nuitka. Gives the following error:
Traceback (most recent call last):
  File "C:\Users\A4F7~1\Desktop\myProg\myProg.py", line 15, in <module>
  File "C:\Users\A4F7~1\Desktop\myProg\oauth2client\service_account.py", line 26, in <module oauth2client.service_account>
  File "C:\Users\A4F7~1\Desktop\myProg\oauth2client\crypt.py", line 23, in <module oauth2client.crypt>
  File "C:\Users\A4F7~1\Desktop\myProg\oauth2client\_pure_python_crypt.py", line 24, in <module oauth2client._pure_python_crypt>
  File "C:\Users\╨Р╨╜╨┤╤А╨╡╨╣\Desktop\myProg\pyasn1_modules\rfc2459.py", line 23, in <module>
    from pyasn1.type import opentype
ImportError: cannot import name 'opentype' from 'pyasn1.type' (C:\Users\A4F7~1\Desktop\myProg\pyasn1\type\__init__.py)

I googled and looked for how to fix it, updated the libraries pip install --upgrade pyasn1-modules, pip install --upgrade google-cloud-storage and others... I manually reinstalled, naturally I threw these reinstalled libraries into the folder with the compiled .exe. Nothing helps. I think it's easier to do something with the ServiceAccountCredentials library, maybe replace it with something, or manually write data for the Creds variable?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Kalashnik, 2021-11-17
@DuxaKievski

Who is so smart that he voted for the "Simple Question", but at the same time he cannot answer it himself?
Okay, I already found a solution to the problem myself, I replaced ServiceAccountCredentials with Google API v4
Who needs it, here's the video:
https://youtu.be/4ssigWmExak

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question