Wie lese ich mit Python in JSON ein? OSError: [Errno 36] Dateiname zu lang:

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie lese ich mit Python in JSON ein? OSError: [Errno 36] Dateiname zu lang:

by Guest » 03 Jan 2025, 18:13

Ich verwende CircleCI, meine Anmeldedaten werden in diesem Schritt entschlüsselt

Code: Select all

echo 'export SERVICE_ACCOUNT_DECODED="$(echo $SERVICE_ACCOUNT | base64 -di)"' >> $BASH_ENV
Später verwende ich Python-Code

Code: Select all

service_account_file = json.dumps(os.environ['SERVICE_ACCOUNT_DECODED'])
# Authenticate using the service account for Google Drive
credentials = service_account.Credentials.from_service_account_file(service_account_file, scopes=SCOPES)
Mein Ziel ist, dass service_account_file JSON ist.
aber es wurde ein Fehler angezeigt

Code: Select all

  File "final_script.py", line 28, in 
credentials = service_account.Credentials.from_service_account_file(service_account_file, scopes=SCOPES)
File "/home/circleci/.pyenv/versions/3.8.20/lib/python3.8/site-packages/google/oauth2/service_account.py", line 260, in from_service_account_file
info, signer = _service_account_info.from_filename(
File "/home/circleci/.pyenv/versions/3.8.20/lib/python3.8/site-packages/google/auth/_service_account_info.py", line 78, in from_filename
with io.open(filename, "r", encoding="utf-8") as json_file:
OSError: [Errno 36] File name too long: '"{\\n
Ich habe json.loads schon einmal ausprobiert, aber es hat auch nicht funktioniert.
Wie kann ich das beheben?

Top