53
53
upsert_service_account_key ,
54
54
)
55
55
from onyx .connectors .google_utils .google_kv import verify_csrf
56
+ from onyx .connectors .google_utils .shared_constants import DB_CREDENTIALS_DICT_TOKEN_KEY
56
57
from onyx .connectors .google_utils .shared_constants import (
57
- DB_CREDENTIALS_DICT_TOKEN_KEY ,
58
+ GoogleOAuthAuthenticationMethod ,
58
59
)
59
60
from onyx .db .connector import create_connector
60
61
from onyx .db .connector import delete_connector
@@ -314,6 +315,7 @@ def upsert_service_account_credential(
314
315
credential_base = build_service_account_creds (
315
316
DocumentSource .GOOGLE_DRIVE ,
316
317
primary_admin_email = service_account_credential_request .google_primary_admin ,
318
+ name = "Service Account (uploaded)" ,
317
319
)
318
320
except KvKeyNotFoundError as e :
319
321
raise HTTPException (status_code = 400 , detail = str (e ))
@@ -408,6 +410,38 @@ def upload_files(
408
410
return FileUploadResponse (file_paths = deduped_file_paths )
409
411
410
412
413
+ @router .get ("/admin/connector" )
414
+ def get_connectors_by_credential (
415
+ _ : User = Depends (current_curator_or_admin_user ),
416
+ db_session : Session = Depends (get_session ),
417
+ credential : int | None = None ,
418
+ ) -> list [ConnectorSnapshot ]:
419
+ """Get a list of connectors. Allow filtering by a specific credential id."""
420
+
421
+ connectors = fetch_connectors (db_session )
422
+
423
+ filtered_connectors = []
424
+ for connector in connectors :
425
+ if connector .source == DocumentSource .INGESTION_API :
426
+ # don't include INGESTION_API, as it's a system level
427
+ # connector not manageable by the user
428
+ continue
429
+
430
+ if credential is not None :
431
+ found = False
432
+ for cc_pair in connector .credentials :
433
+ if credential == cc_pair .credential_id :
434
+ found = True
435
+ break
436
+
437
+ if not found :
438
+ continue
439
+
440
+ filtered_connectors .append (ConnectorSnapshot .from_connector_db_model (connector ))
441
+
442
+ return filtered_connectors
443
+
444
+
411
445
# Retrieves most recent failure cases for connectors that are currently failing
412
446
@router .get ("/admin/connector/failed-indexing-status" )
413
447
def get_currently_failed_indexing_status (
@@ -987,7 +1021,12 @@ def gmail_callback(
987
1021
credential_id = int (credential_id_cookie )
988
1022
verify_csrf (credential_id , callback .state )
989
1023
credentials : Credentials | None = update_credential_access_tokens (
990
- callback .code , credential_id , user , db_session , DocumentSource .GMAIL
1024
+ callback .code ,
1025
+ credential_id ,
1026
+ user ,
1027
+ db_session ,
1028
+ DocumentSource .GMAIL ,
1029
+ GoogleOAuthAuthenticationMethod .UPLOADED ,
991
1030
)
992
1031
if credentials is None :
993
1032
raise HTTPException (
@@ -1013,7 +1052,12 @@ def google_drive_callback(
1013
1052
verify_csrf (credential_id , callback .state )
1014
1053
1015
1054
credentials : Credentials | None = update_credential_access_tokens (
1016
- callback .code , credential_id , user , db_session , DocumentSource .GOOGLE_DRIVE
1055
+ callback .code ,
1056
+ credential_id ,
1057
+ user ,
1058
+ db_session ,
1059
+ DocumentSource .GOOGLE_DRIVE ,
1060
+ GoogleOAuthAuthenticationMethod .UPLOADED ,
1017
1061
)
1018
1062
if credentials is None :
1019
1063
raise HTTPException (
0 commit comments