[PYTHON] Abhilfe für Es konnte kein Schlüssel erkannt werden.

Fehlerprotokoll

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.7/site-packages/firebase_admin/credentials.py", line 96, in __init__
    json_data, scopes=_scopes)
  File "/app/.heroku/python/lib/python3.7/site-packages/google/oauth2/service_account.py", line 201, in from_service_account_info
    info, require=["client_email", "token_uri"]
  File "/app/.heroku/python/lib/python3.7/site-packages/google/auth/_service_account_info.py", line 55, in from_dict
    signer = crypt.RSASigner.from_service_account_info(data)
  File "/app/.heroku/python/lib/python3.7/site-packages/google/auth/crypt/base.py", line 114, in from_service_account_info
    info[_JSON_FILE_PRIVATE_KEY], info.get(_JSON_FILE_PRIVATE_KEY_ID)
  File "/app/.heroku/python/lib/python3.7/site-packages/google/auth/crypt/_python_rsa.py", line 171, in from_string
    raise ValueError("No key could be detected.")
ValueError: No key could be detected.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 28, in <module>
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-vbo7h%40jun-remind.iam.gserviceaccount.com"
  File "/app/.heroku/python/lib/python3.7/site-packages/firebase_admin/credentials.py", line 99, in __init__
    'Caused by: "{0}"'.format(error))
ValueError: Failed to initialize a certificate credential. Caused by: "No key could be detected."

Ansatz

  1. Ändern Sie den Schlüssel der Heroku-Umgebungsvariablen in Großbuchstaben
  2. Konvertieren Sie den Zeilenvorschubcode von private_key
os.environ["PRIVATE_KEY"].replace('\\n', '\n')

Referenz

https://github.com/firebase/firebase-admin-python/issues/188

Recommended Posts

Abhilfe für Es konnte kein Schlüssel erkannt werden.
So protokollieren Sie mit Python (wenn für den Logger keine Handler gefunden wurden "__main__" wird angezeigt)