@@ -1266,6 +1266,7 @@ private static String federatedFlowStep3(SFLoginInput loginInput, String tokenUr
1266
1266
throws SnowflakeSQLException {
1267
1267
1268
1268
String oneTimeToken = "" ;
1269
+ boolean isMfaEnabledInOkta ;
1269
1270
try {
1270
1271
URL url = new URL (tokenUrl );
1271
1272
URI tokenUri = url .toURI ();
@@ -1302,17 +1303,32 @@ private static String federatedFlowStep3(SFLoginInput loginInput, String tokenUr
1302
1303
null ,
1303
1304
loginInput .getHttpClientSettingsKey ());
1304
1305
1305
- logger .debug ("User is authenticated against {}." , loginInput .getAuthenticator ());
1306
-
1307
1306
// session token is in the data field of the returned json response
1308
1307
final JsonNode jsonNode = mapper .readTree (idpResponse );
1308
+ isMfaEnabledInOkta = jsonNode .get ("status" ).asText ().equals ("MFA_REQUIRED" );
1309
+ if (isMfaEnabledInOkta ) {
1310
+ SnowflakeSQLException ex =
1311
+ new SnowflakeSQLLoggedException (
1312
+ null ,
1313
+ ErrorCode .OKTA_MFA_NOT_SUPPORTED .getMessageCode (),
1314
+ SqlState .FEATURE_NOT_SUPPORTED ,
1315
+ "MFA enabled in Okta is not supported with this authenticator type. "
1316
+ + "Please use 'externalbrowser' instead or a different authentication method." );
1317
+
1318
+ logger .error (
1319
+ "MFA enabled in Okta is not supported with this authenticator type. "
1320
+ + "Please use 'externalbrowser' instead or a different authentication method." ,
1321
+ ex );
1322
+ throw ex ;
1323
+ }
1309
1324
oneTimeToken =
1310
1325
jsonNode .get ("sessionToken" ) != null
1311
1326
? jsonNode .get ("sessionToken" ).asText ()
1312
1327
: jsonNode .get ("cookieToken" ).asText ();
1313
1328
} catch (IOException | URISyntaxException ex ) {
1314
1329
handleFederatedFlowError (loginInput , ex );
1315
1330
}
1331
+ logger .debug ("User is authenticated against {}." , loginInput .getAuthenticator ());
1316
1332
return oneTimeToken ;
1317
1333
}
1318
1334
0 commit comments