fix: correct Google OAuth client ID and add auth diagnostics

- Updated RELEASE_GOOGLE_OAUTH_ID GitHub secret to use web client ID
  (client_type 3) instead of Android client ID (client_type 1).
  requestIdToken() requires the web/server client ID.
- Added diagnostic logging to Google Sign-In flow to capture exact
  error codes (ApiException statusCode) and OAuth client ID in use.
This commit is contained in:
2026-02-27 00:44:36 +03:00
parent ef1c71a320
commit 40f1b9bcaa
@@ -28,6 +28,7 @@ import io.novafoundation.nova.common.utils.mapErrorNotInstance
import io.novafoundation.nova.common.utils.systemCall.SystemCall
import io.novafoundation.nova.common.utils.systemCall.SystemCallExecutor
import io.novafoundation.nova.feature_cloud_backup_api.domain.model.errors.FetchBackupError
import android.util.Log
import io.novafoundation.nova.feature_cloud_backup_impl.BuildConfig
import io.novafoundation.nova.feature_cloud_backup_impl.data.ReadyForStorageBackup
import kotlinx.coroutines.Dispatchers
@@ -70,8 +71,18 @@ internal class GoogleDriveBackupStorage(
}
override suspend fun authenticateUser(): Result<Unit> = withContext(Dispatchers.IO) {
Log.d(
"GoogleDriveBackup",
"authenticateUser: oauthClientId=${oauthClientId.take(20)}..."
)
val systemCall = GoogleSignInSystemCall(contextManager, oauthClientId, driveScope())
systemCallExecutor.executeSystemCall(systemCall)
val result = systemCallExecutor.executeSystemCall(systemCall)
Log.d(
"GoogleDriveBackup",
"authenticateUser result: success=${result.isSuccess}" +
"${result.exceptionOrNull()?.let { ", error=${it::class.simpleName}: ${it.message}" } ?: ""}"
)
result
}
override suspend fun checkBackupExists(): Result<Boolean> = withContext(Dispatchers.IO) {
@@ -110,6 +121,11 @@ internal class GoogleDriveBackupStorage(
private suspend fun <T> runCatchingRecoveringAuthErrors(action: suspend () -> T): Result<T> {
return runCatching { action() }
.recoverCatching {
Log.e(
"GoogleDriveBackup",
"Drive operation failed: ${it::class.simpleName}: ${it.message}",
it
)
when (it) {
is UserRecoverableAuthException -> it.askForConsent()
is UserRecoverableAuthIOException -> it.cause?.askForConsent()
@@ -249,10 +265,18 @@ private class GoogleSignInSystemCall(
val task: Task<GoogleSignInAccount> = GoogleSignIn.getSignedInAccountFromIntent(intent)
return try {
task.getResult(ApiException::class.java)
val account = task.getResult(ApiException::class.java)
Log.d(
"GoogleDriveBackup",
"Sign-in success: email=${account?.email}, idToken=${account?.idToken?.take(20) ?: "null"}"
)
Result.success(Unit)
} catch (e: ApiException) {
Log.e(
"GoogleDriveBackup",
"Sign-in failed: statusCode=${e.statusCode}, message=${e.message}",
e
)
Result.failure(e)
}
}