エラーログ
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."
対処法
- herokuの環境変数のキーを大文字に変更
- private_keyの改行コードを変換
os.environ["PRIVATE_KEY"].replace('\\n', '\n')
参考