franz101 commited on
Commit
19d82a1
1 Parent(s): 16b4a0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -16
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import json
3
  from google.oauth2 import service_account
 
4
 
5
  from langchain.llms import OpenAI
6
  from langchain.chat_models import ChatOpenAI
@@ -14,22 +15,15 @@ PROJECT_ID = "franz-media-1512554302520"
14
  LOCATION = "us-central1"
15
  CRED_PATH = "creds.json"
16
 
17
- creds = json.dumps({
18
- "type": "service_account",
19
- "project_id": PROJECT_ID,
20
- "private_key_id": os.environ["GCP_PRIVATE_KEY_ID"],
21
- "private_key": os.environ["GCP_PRIVATE_KEY"],
22
- "client_email": f"{PROJECT_ID}@appspot.gserviceaccount.com",
23
- "client_id": "113564988595294446487",
24
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
25
- "token_uri": "https://oauth2.googleapis.com/token",
26
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
27
- "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/franz-media-1512554302520%40appspot.gserviceaccount.com",
28
- "universe_domain": "googleapis.com"
29
- })
30
-
31
- with open(CRED_PATH,"w") as f:
32
- f.write(creds)
33
 
34
  print("stored")
35
 
 
1
  import os
2
  import json
3
  from google.oauth2 import service_account
4
+ from cryptography.fernet import Fernet
5
 
6
  from langchain.llms import OpenAI
7
  from langchain.chat_models import ChatOpenAI
 
15
  LOCATION = "us-central1"
16
  CRED_PATH = "creds.json"
17
 
18
+ with open("key.json","w") as f:
19
+ encrypted_data = f.read()
20
+
21
+ cipher_suite = Fernet(os.environ["ENCRYPTION_KEY"])
22
+ decrypted_data = cipher_suite.decrypt(encrypted_data)
23
+
24
+
25
+ with open(CRED_PATH,"wb") as f:
26
+ f.write(decrypted_data)
 
 
 
 
 
 
 
27
 
28
  print("stored")
29