diff --git a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/RealmSyncUtils.kt b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/RealmSyncUtils.kt index b86783b6f0..af5463f9a4 100644 --- a/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/RealmSyncUtils.kt +++ b/packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/RealmSyncUtils.kt @@ -200,6 +200,10 @@ internal fun convertAppError(appError: AppError): Throwable { // Custom JWT // See https://github.com/10gen/baas/blob/master/authprovider/providers/custom/provider.go InvalidCredentialsException(msg) + } else if (msg.contains("unauthorized")) { + // Sanitized error messages + // See https://github.com/10gen/baas/pull/14005/files + InvalidCredentialsException(msg) } else { // It does not look possible to reliably detect Facebook, Google and Apple // invalid tokens: https://github.com/10gen/baas/blob/master/authprovider/providers/oauth2/oauth.go#L139 diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/CredentialsTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/CredentialsTests.kt index b666ebb3dc..d76391c980 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/CredentialsTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/CredentialsTests.kt @@ -369,7 +369,7 @@ class CredentialsTests { payload = mapOf("mail" to TestHelper.randomEmail(), "id" to 0) ) - assertFailsWithMessage("Error: Authentication failed.") { + assertFailsWithMessage("unauthorized") { runBlocking { app.login(credentials) } @@ -383,7 +383,7 @@ class CredentialsTests { } fail() } catch (error: AppException) { - assertTrue(error.message!!.contains("authentication via"), error.message) + assertTrue(error.message!!.contains("unauthorized"), error.message) } } }