Search code examples
pythonfirebasefirebase-admin

How can I get a Url that include Path of a Json File instead of Passing the Locally Path Using Firebase


Is there any way to upload the Credential File to the Firebase and only pass a path for this file from firebase to authenticate.

For Example:

here I need to pass the credential file which is in my local computer I need to pass a path from the internet maybe by uploading the credential file "serviceAccountKey.json" to the firebase and get a Url which include the path of this file on the internet.

cred = credentials.Certificate("path/to/serviceAccountKey.json")

Thanks.


Solution

  • I Solved This issue Instead of Generating a URL Which include the Path of the Json Credentials File and it won't be secure I solved it by Creating a New Json File then passing the name of the New Json File to the Credentials File Path It Works:

    firebase_credentials = {
      "type": "",
      "project_id": "",
      "private_key_id": "",
      "private_key": "-----BEGIN PRIVATE KEY-----
    -----END PRIVATE KEY-----\n",
          "client_email": "",
          "client_id": "",
          "auth_uri": "",
          "token_uri": "",
          "auth_provider_x509_cert_url": "",
          "client_x509_cert_url": ""
        }
        with open("firebase_credentials.json", "w") as write_file:
            json.dump(firebase_credentials, write_file)
        cred_obj = firebase_admin.credentials.Certificate('firebase_credentials.json')
    

    And That's It GOOD LUCK...