heaversm commited on
Commit
9222bcf
1 Parent(s): 7a2e70c

try different auth method

Browse files
Files changed (2) hide show
  1. app.py +11 -2
  2. requirements.txt +3 -1
app.py CHANGED
@@ -34,7 +34,9 @@ import uuid #for generating unique filenames
34
  # GCP credentials stuff
35
  import json
36
  import tempfile
37
-
 
 
38
 
39
  load_dotenv()
40
 
@@ -77,7 +79,14 @@ def get_creds_json():
77
  return json.loads(creds_json_str)
78
 
79
  # pass
80
- os.environ["GOOGLE_APPLICATION_CREDENTIALS"]= get_creds_json()
 
 
 
 
 
 
 
81
 
82
  # pick a random challenge
83
  def get_challenge():
 
34
  # GCP credentials stuff
35
  import json
36
  import tempfile
37
+ import pybase64
38
+ from google.oauth2 import service_account
39
+ import google.auth
40
 
41
  load_dotenv()
42
 
 
79
  return json.loads(creds_json_str)
80
 
81
  # pass
82
+ # service_acct_json = open(pdr-imagen-encoded.json')
83
+ service_account_json = pybase64.b64decode(os.getenv("IMAGEN"))
84
+ service_account_info = json.loads(service_account_json)
85
+ credentials = service_account.Credentials.from_service_account_info(service_account_info)
86
+ #os.environ["GOOGLE_APPLICATION_CREDENTIALS"]= get_creds_json()
87
+ project="pdr-imagen"
88
+ aiplatform.init(project=project, credentials=credentials)
89
+
90
 
91
  # pick a random challenge
92
  def get_challenge():
requirements.txt CHANGED
@@ -3,4 +3,6 @@ openai==1.2.3
3
  python-dotenv==1.0.0
4
  pymongo
5
  google-cloud-aiplatform>=1.38
6
- pillow==10.2.0
 
 
 
3
  python-dotenv==1.0.0
4
  pymongo
5
  google-cloud-aiplatform>=1.38
6
+ pillow==10.2.0
7
+ google==3.0.0
8
+ pybase64==1.3.2