Google Sign In error 12500

前端 未结 30 3781
时光说笑
时光说笑 2020-11-22 09:17

I am trying to integrate Google Sign In into my app. I don\'t have a back-end server, I am just getting the details of the logged on Google Account to my app.

I firs

相关标签:
30条回答
  • 2020-11-22 10:07

    Error PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null)

    This 12500 Error can be solved by adding a support email address to your project in project settings. Open link https://console.firebase.google.com/

    Select Your project and open settings tab.

    Provide a valid support email and restart your application now.

    0 讨论(0)
  • 2020-11-22 10:08

    https://developers.google.com/identity/sign-in/android/sign-in follow this api documentation but keep in mind that inside WEB_CLIENT_ID use the value of client id which is generated inside google-services.json file.

    class MainActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFailedListener {
    private val TAG = "JSAGoogleSignIn"
    private val REQUEST_CODE_SIGN_IN = 1234
    private val WEB_CLIENT_ID = "354298333018-XXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com"
    private var mAuth: FirebaseAuth? = null
    
    private var mGoogleApiClient: GoogleApiClient? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        var txt_register = findViewById<TextView>(R.id.txt_register)
        txt_register.setOnClickListener {
            var intent = Intent(this@MainActivity, RegisterActivity::class.java)
            finish()
            startActivity(intent)
        }
        val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(WEB_CLIENT_ID)
                .requestEmail()
                .build()
        mGoogleApiClient = GoogleApiClient.Builder(this)
                .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build()
    
        mAuth = FirebaseAuth.getInstance()
        sign_in_button.setOnClickListener {
            val intent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient)
            startActivityForResult(intent, REQUEST_CODE_SIGN_IN)
        }
    
    }
    
    
    override fun onConnectionFailed(p0: ConnectionResult) {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }
    
    
    private fun updateUI(user: FirebaseUser?) {
        if (user != null) {
            Log.e("Email", "Value" + user.email)
        }
    
    }
    
    fun signIn() {
    
    }
    
    override fun onStart() {
        super.onStart()
        val currentUser = mAuth!!.currentUser
        updateUI(currentUser)
    }
    
    public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
    
        // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
        if (requestCode == REQUEST_CODE_SIGN_IN) {
            val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
            if (result.isSuccess) {
                // successful -> authenticate with Firebase
                val account = result.signInAccount
                firebaseAuthWithGoogle(account!!)
            } else {
                // failed -> update UI
                updateUI(null)
                Toast.makeText(applicationContext, "SignIn: failed!" + result.status,
                        Toast.LENGTH_SHORT).show()
            }
        }
    }
    
    private fun firebaseAuthWithGoogle(acct: GoogleSignInAccount) {
        Log.e(TAG, "firebaseAuthWithGoogle():" + acct.id!!)
    
        val credential = GoogleAuthProvider.getCredential(acct.idToken, null)
        mAuth!!.signInWithCredential(credential)
                .addOnCompleteListener(this) { task ->
                    if (task.isSuccessful) {
                        // Sign in success
                        Log.e(TAG, "signInWithCredential: Success!")
                        val user = mAuth!!.currentUser
                        updateUI(user)
                    } else {
                        // Sign in fails
                        Log.w(TAG, "signInWithCredential: Failed!", task.exception)
                        Toast.makeText(applicationContext, "Authentication failed!",
                                Toast.LENGTH_SHORT).show()
                        updateUI(null)
                    }
                }
    }
    
    0 讨论(0)
  • 2020-11-22 10:10

    If there's still anyone out there with a similar issue, if you're adding custom scopes, make sure it's a valid scope. In my case, I mixed Facebook scopes with Google scopes and took me a while to figure it out!

    0 讨论(0)
  • 2020-11-22 10:10

    Make sure your project should not contain any special character including numeric or any kind of symbol(project name should be simple as com.google.testproject)

    0 讨论(0)
  • 2020-11-22 10:11

    If you are coming here from flutter : This is one of the corner cases we have to fix as per the documentation here : https://pub.dev/packages/google_sign_in

    • Go to Google APIs & Sevices
    • Select the app you want to implement google signin In to.
    • Then click on Enable APIS and Services

    • Then Search for Google Peoples API

    • Open the Google People API card and click enable, your app might get rid of the issue.
    0 讨论(0)
  • 2020-11-22 10:12

    In my case, After adding fingerprint in Firebase console, it got automatically picked up by the Google developer console and shown the fingerprints. But sign in did not work. After looking at every step, I figured that Google reversed my manifest file package like this com.xxxxxxxx.app. But it is actually app.xxxxxxxx.com, in Google developer console. So I deleted auto created a fingerprint and added fingerprint with the correct package name. BOOM!!. It worked.

    0 讨论(0)
提交回复
热议问题