achuthc1298 commited on
Commit
f091c04
·
verified ·
1 Parent(s): f5fcf59

Update google_api_deploy.py

Browse files
Files changed (1) hide show
  1. google_api_deploy.py +11 -1
google_api_deploy.py CHANGED
@@ -7,6 +7,16 @@ from google_auth_oauthlib.flow import InstalledAppFlow
7
  from google.auth.transport.requests import Request
8
  from googleapiclient.http import MediaIoBaseUpload
9
 
 
 
 
 
 
 
 
 
 
 
10
  # If modifying these SCOPES, delete the file token.pickle.
11
  SCOPES = ['https://www.googleapis.com/auth/drive']
12
 
@@ -21,7 +31,7 @@ def authenticate_google_drive():
21
  creds.refresh(Request())
22
  else:
23
  flow = InstalledAppFlow.from_client_secrets_file(
24
- 'credentials.json', SCOPES)
25
  creds = flow.run_local_server(port=0)
26
  with open('token.pickle', 'wb') as token:
27
  pickle.dump(creds, token)
 
7
  from google.auth.transport.requests import Request
8
  from googleapiclient.http import MediaIoBaseUpload
9
 
10
+ google_client_secrets_json = os.getenv('GOOGLE_CLIENT_SECRETS')
11
+
12
+ # Parse the JSON data for Google client secrets
13
+ google_client_secrets = json.loads(google_client_secrets_json)
14
+
15
+ # Save the client secrets to a temporary file
16
+ with open('temp_credentials.json', 'w') as temp_file:
17
+ json.dump(google_client_secrets, temp_file)
18
+
19
+
20
  # If modifying these SCOPES, delete the file token.pickle.
21
  SCOPES = ['https://www.googleapis.com/auth/drive']
22
 
 
31
  creds.refresh(Request())
32
  else:
33
  flow = InstalledAppFlow.from_client_secrets_file(
34
+ 'temp_credentials.json', SCOPES)
35
  creds = flow.run_local_server(port=0)
36
  with open('token.pickle', 'wb') as token:
37
  pickle.dump(creds, token)