mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-04-21 23:48:00 +00:00
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:
+27
-3
@@ -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.SystemCall
|
||||||
import io.novafoundation.nova.common.utils.systemCall.SystemCallExecutor
|
import io.novafoundation.nova.common.utils.systemCall.SystemCallExecutor
|
||||||
import io.novafoundation.nova.feature_cloud_backup_api.domain.model.errors.FetchBackupError
|
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.BuildConfig
|
||||||
import io.novafoundation.nova.feature_cloud_backup_impl.data.ReadyForStorageBackup
|
import io.novafoundation.nova.feature_cloud_backup_impl.data.ReadyForStorageBackup
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -70,8 +71,18 @@ internal class GoogleDriveBackupStorage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun authenticateUser(): Result<Unit> = withContext(Dispatchers.IO) {
|
override suspend fun authenticateUser(): Result<Unit> = withContext(Dispatchers.IO) {
|
||||||
|
Log.d(
|
||||||
|
"GoogleDriveBackup",
|
||||||
|
"authenticateUser: oauthClientId=${oauthClientId.take(20)}..."
|
||||||
|
)
|
||||||
val systemCall = GoogleSignInSystemCall(contextManager, oauthClientId, driveScope())
|
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) {
|
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> {
|
private suspend fun <T> runCatchingRecoveringAuthErrors(action: suspend () -> T): Result<T> {
|
||||||
return runCatching { action() }
|
return runCatching { action() }
|
||||||
.recoverCatching {
|
.recoverCatching {
|
||||||
|
Log.e(
|
||||||
|
"GoogleDriveBackup",
|
||||||
|
"Drive operation failed: ${it::class.simpleName}: ${it.message}",
|
||||||
|
it
|
||||||
|
)
|
||||||
when (it) {
|
when (it) {
|
||||||
is UserRecoverableAuthException -> it.askForConsent()
|
is UserRecoverableAuthException -> it.askForConsent()
|
||||||
is UserRecoverableAuthIOException -> it.cause?.askForConsent()
|
is UserRecoverableAuthIOException -> it.cause?.askForConsent()
|
||||||
@@ -249,10 +265,18 @@ private class GoogleSignInSystemCall(
|
|||||||
val task: Task<GoogleSignInAccount> = GoogleSignIn.getSignedInAccountFromIntent(intent)
|
val task: Task<GoogleSignInAccount> = GoogleSignIn.getSignedInAccountFromIntent(intent)
|
||||||
|
|
||||||
return try {
|
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)
|
Result.success(Unit)
|
||||||
} catch (e: ApiException) {
|
} catch (e: ApiException) {
|
||||||
|
Log.e(
|
||||||
|
"GoogleDriveBackup",
|
||||||
|
"Sign-in failed: statusCode=${e.statusCode}, message=${e.message}",
|
||||||
|
e
|
||||||
|
)
|
||||||
Result.failure(e)
|
Result.failure(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user