@@ -1189,15 +1189,6 @@ def integration_from_service_account(
11891189 token_uri : str | None = None ,
11901190 created_by : User | None = None ,
11911191 ) -> Integration :
1192- sensitive_config = {}
1193-
1194- is_impersonated = True
1195- if isinstance (private_key , str ) and isinstance (private_key_id , str ) and isinstance (token_uri , str ):
1196- sensitive_config ["private_key" ] = private_key
1197- sensitive_config ["private_key_id" ] = private_key_id
1198- sensitive_config ["token_uri" ] = token_uri
1199- is_impersonated = False
1200-
12011192 # Do not allow the same project_id in multiple organizations
12021193 same_service_account_integrations = Integration .objects .select_related ("team__organization" ).filter (
12031194 kind = "google-cloud-service-account" , config__service_account_email = service_account_email
@@ -1206,6 +1197,15 @@ def integration_from_service_account(
12061197 if str (integration .team .organization .id ) != str (organization_id ):
12071198 raise ValidationError ("Cannot create Google Cloud service account integration: Invalid service account" )
12081199
1200+ sensitive_config = {}
1201+ is_impersonated = True
1202+ if isinstance (private_key , str ) and isinstance (private_key_id , str ) and isinstance (token_uri , str ):
1203+ sensitive_config ["private_key" ] = private_key
1204+ sensitive_config ["private_key_id" ] = private_key_id
1205+ sensitive_config ["token_uri" ] = token_uri
1206+
1207+ is_impersonated = False
1208+
12091209 variant = "impersonated" if is_impersonated else "key-file"
12101210
12111211 integration , _ = Integration .objects .update_or_create (
0 commit comments