GVAmaresh commited on
Commit
98b5869
·
1 Parent(s): 0376d10

dev: check working

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py CHANGED
@@ -213,3 +213,49 @@ if os.path.exists(file_path):
213
  print(f"The file '{output_file}' exists at '{file_path}'.")
214
  else:
215
  print(f"The file '{output_file}' does not exist at '{file_path}'.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  print(f"The file '{output_file}' exists at '{file_path}'.")
214
  else:
215
  print(f"The file '{output_file}' does not exist at '{file_path}'.")
216
+
217
+ #-----------------------------------------------------------------------------------------
218
+ import os
219
+ from dotenv import load_dotenv
220
+ from googleapiclient.discovery import build
221
+ from google_auth_oauthlib.flow import InstalledAppFlow
222
+ from google.auth.transport.requests import Request
223
+ from google.oauth2.credentials import Credentials
224
+ from google.oauth2 import service_account
225
+
226
+ SCOPES = ['https://www.googleapis.com/auth/drive']
227
+
228
+
229
+ details = {
230
+ "refresh_token": "1//0gYLCF5OE4fTmCgYIARAAGBASNwF-L9Irp3Ik0q5OtsQClcLwW7sxPZSuMboe7wyjteuSuOD_WvavEHfhuTvkSjkLHitkh76XaD4",
231
+ "token": "ya29.a0ARW5m753vyDgN_C7kUnnYTkeCfknSnDDj8tuVCe99dL2ieN3IzvCPVoN5kVg49CAYDz-pS5AgpjH7whiy7dr7QhwX4EiGQreJCzu109nlH6kxultrNup5q-_W2dNepbOa5YV8iH7OwP28RjQVR7fs9IlMO7BfnA9hw-WQqXNaCgYKAXMSARMSFQHGX2MieHrC7CpySZFYpoZWln6vxA0175",
232
+ "token_uri": "https://oauth2.googleapis.com/token",
233
+ "client_id": "573421158717-a2tulr4s7gg6or7sd76336busnmk22vu.apps.googleusercontent.com",
234
+ "client_secret": "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",
235
+ "scopes": ["https://www.googleapis.com/auth/drive"],
236
+ "universe_domain": "googleapis.com",
237
+ "account": "",
238
+ }
239
+
240
+
241
+ def main():
242
+ try:
243
+ print(details)
244
+ creds = None
245
+ creds = Credentials.from_authorized_user_info(details, SCOPES)
246
+
247
+ if not creds or not creds.valid:
248
+ if creds and creds.expired and creds.refresh_token:
249
+ creds.refresh(Request())
250
+ else:
251
+ flow = InstalledAppFlow.from_client_secrets_file(
252
+ 'credentials.json', SCOPES)
253
+ creds = flow.run_local_server(port=0)
254
+
255
+ service = build('drive', 'v3', credentials=creds)
256
+ return service
257
+
258
+ except Exception as error:
259
+ print(f'An error occurred: {error}')
260
+
261
+