在 Play 管理中心中签署应用后,Google 登录将停止工作

问题描述 投票:0回答:1

该主题有很多答案,但大多数都与 Firebase 相关,即使我尝试使用或不使用 Firebase,我也会收到相同的一般错误

Exception com.google.android.gms.common.api.ApiException: 10: Developer console is not setup correctly.

问题:

使用任何构建(调试、发布),虽然我们有 CI-CD 通过 AppCenter 部署和分发应用程序,但在所有环境(测试、生产)中一切都很好,但是,一旦我们在 Google Play Console 中发布应用程序或使用 Play Console 中的 App Bundle Explorer 上传 AAB 并下载 APK 以在设备上进行本地测试,Google Sign-on 不起作用。

经过两周的研究并试图理解这意味着什么后,我做了以下事情。

  • 在 Google Play 管理中心重置上传密钥
  • 在 Google Play 管理中心重置 Google Play 应用签名密钥
  • 在 Google Cloud Console 中重新创建了 Android 凭据(重新创建 Web 客户端 - 甚至尝试了 Firebase 自动创建的凭据)
  • 尝试使用 Firebase 应用程序
  • 最新文档中的代码 (https://developers.google.com/identity/one-tap/android/overview)
  • Firebase YouTube 视频 (https://youtu.be/zCIfBbm06QM?si=FlHtl7Hwk6xZc8KQ)
  • Android Kotlin 代码库是使用模块构建的,将身份验证模块移至主模块应用程序中(尝试排除模块中不同的包名称)
  • 创建了一个干净的 Android Kotlin 项目,仅包含一个 Google 登录按钮(相同的错误)
  • 确保多次使用 Web 客户端 OAuth 客户端 ID(好吧,如果不这样做的话,将会出现有意义的错误)
  • 我已提交 Google Could OAuth Screen 同意书以供批准,但仍在等待批准。我不认为这是一个问题,因为我们请求敏感范围。

我只有一个使用上传密钥 SHA1 的 Google Cloud Android OAuth 客户端 ID(我尝试使用 Google Play 签名 SHA1 添加第二个客户端 ID,但并没有真正改变任何内容)。这是尝试解决此答案中的问题https://stackoverflow.com/a/41034093/122769。 我实际上使用相同的 SHA1 进行调试和发布。请参阅下面的登录报告。另一个答案,但又与使用 Firebase 有关(https://stackoverflow.com/a/68094280/122769)。 我有一种感觉,我可能在需要为构建使用不同的 SHA1 方面做错了什么;但不确定如何处理它(不知道如何/在哪里添加 SHA1 进行发布https://stackoverflow.com/a/39347133/122769

./gradlew signingReport

Variant: testRelease
Config: config
Store: some_path_to_store/release.jks
Alias: company
MD5: 57:MD5
SHA1: 99:SHA1
SHA-256: C3:SHA256
Valid until: Thursday, Month 9, 2045

Variant: prodRelease
Config: config
Store: some_path_to_store/release.jks
Alias: company
MD5: 57:MD5
SHA1: 99:SHA1
SHA-256: C3:SHA256
Valid until: Thursday, Month 9, 2045

代码:

package com.eight.app

import android.content.IntentSender
import android.os.Bundle
import android.util.Log
import android.widget.TextView
import androidx.activity.result.ActivityResult
import androidx.activity.result.IntentSenderRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import com.google.android.gms.auth.api.identity.BeginSignInRequest
import com.google.android.gms.auth.api.identity.Identity
import com.google.android.gms.auth.api.identity.SignInClient
import com.google.android.gms.common.api.ApiException

class MainActivity : AppCompatActivity() {

    private lateinit var errorText: TextView
    private lateinit var googleButton: TextView
    private lateinit var oneTapClient: SignInClient
    private lateinit var signInRequest: BeginSignInRequest
    private val activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult(), ::handleSignInResult)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.a_start)
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
        errorText = findViewById(R.id.errorText)
        googleButton = findViewById(R.id.googleButton)

        oneTapClient = Identity.getSignInClient(this)
        signInRequest = BeginSignInRequest.builder()
            .setPasswordRequestOptions(
                BeginSignInRequest.PasswordRequestOptions.builder()
                    .setSupported(true)
                    .build(),
            )
            .setGoogleIdTokenRequestOptions(
                BeginSignInRequest.GoogleIdTokenRequestOptions.builder()
                    .setSupported(true)
                    // Your server's client ID, not your Android client ID.
                    .setServerClientId(getString(R.string.your_web_client_id))
                    // Only show accounts previously used to sign in.
                    .setFilterByAuthorizedAccounts(false)
                    .build(),
            )
            // Automatically sign in when exactly one credential is retrieved.
            .setAutoSelectEnabled(true)
            .build()

        googleButton.setOnClickListener {
            oneTapClient.beginSignIn(signInRequest)
                .addOnSuccessListener(this) { result ->
                    try {
                        val intentSenderRequest = IntentSenderRequest.Builder(result.pendingIntent.intentSender).build()
                        activityResultLauncher.launch(intentSenderRequest)
                    } catch (e: IntentSender.SendIntentException) {
                        Log.e("oneTapSignIn", "Couldn't start One Tap UI: ${e.localizedMessage}")
                        errorText.text = "oneTapSignIn Couldn't start One Tap UI: ${e.localizedMessage}"
                    }
                }
                .addOnFailureListener(this) { e ->
                    // No Google Accounts found. Just continue presenting the signed-out UI.
                    Log.d("oneTapSignIn", e.localizedMessage)
                    errorText.text = "oneTapSignIn addOnFailureListener Couldn't start One Tap UI: ${e.localizedMessage}"
                }
        }
    }

    private fun handleSignInResult(result: ActivityResult) {
        try {
            val credential = oneTapClient.getSignInCredentialFromIntent(result.data)
            val idToken = credential.googleIdToken
            when {
                idToken != null -> {
                    // Got an ID token from Google. Use it to authenticate
                    // with your backend.
                    errorText.text = "Token Success GOt token $idToken"

                    Log.d("onActivityResult", "Got ID token.")
                }

                else -> {
                    // Shouldn't happen.
                    Log.d("onActivityResult", "No ID token!")
                    errorText.text = "No ID token!"
                }
            }
        } catch (e: ApiException) {
            Log.d("onActivityResult", "ApiException No ID token!")
            errorText.text = "Exception $e \n${e.localizedMessage} \n${e.message} \n ${e.cause} \n${e.stackTrace}!"
        }
    }
}

理想情况下,我想避免使用 Firebase,但无论如何,这仍然不起作用。有没有办法获得更多相关的调试信息?任何有关测试解决方案的想法将不胜感激:)

android google-signin google-one-tap
1个回答
0
投票

您需要复制在 Play 控制台中生成的新 SHA-1 并将其添加到 Firebase / GCP 中

© www.soinside.com 2019 - 2024. All rights reserved.