LoginSignup
3
2

More than 3 years have passed since last update.

No key could be detected.の対処法メモ

Posted at

エラーログ

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."

対処法

  1. herokuの環境変数のキーを大文字に変更
  2. private_keyの改行コードを変換
os.environ["PRIVATE_KEY"].replace('\\n', '\n')

参考

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2