最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - Using Credential Manager for google login, keep getting "invalid user" after successfully sign in -

programmeradmin1浏览0评论

I am trying to archive sign in with google account, was able to do it.
But the problem is, after one time sign in successfully, I cannot sign in with the account.
It looks like only new accounts works, and the accounts which already signed in are all returning error messages saying "invalid user".

I checked the differences between new accounts and the others.

when (credential) {
            // GoogleIdToken credential
            is CustomCredential -> {
                if (credential.type == GoogleIdTokenCredential.TYPE_GOOGLE_ID_TOKEN_CREDENTIAL) {
                    try {
                        val googleIdTokenCredential = GoogleIdTokenCredential.createFrom(credential.data)

                        Log.e("LOGIN", "googleIdTokenCredential: ${googleIdTokenCredential}")
                        Log.e("LOGIN", "Google ID : ${googleIdTokenCredential.id}")
                        Log.e("LOGIN", "Display Name: ${googleIdTokenCredential.displayName}")
                        Log.e("LOGIN", "Email: ${googleIdTokenCredential.id}")

And the Logs shows when it's new account,

Google ID : [email protected]
Display Name: Test Name
Email: [email protected]

Then when it's not a new account, it looks like this.

Google ID : 105392828937394874235
Display Name: null
Email: 105392828937394874235

There is something suspicious, and it seems that I made a foolish mistake with the SHA-1 key.

When I first registered the project in the Firebase Console and created an OAuth 2.0 client ID in the Google Cloud Console, I entered an SHA-1 value that started with B1:98.... Then by mistake, I fot the debug.keystore that was generated at that time and created a new debug.keystore. After that, I updated the newly obtained SHA-1 value in both the Firebase Console and Google Cloud Console, then built the app again.

At that time, I tested three accounts: A, B, and C. Account A had logged in before the SHA-1 value was changed, while B and C had not. When attempting to log in, A received an "invalid user" error, whereas B and C were able to log in successfully, even after multiple attempts.

Next day, I restored the original debug.keystore, then rebuilt the app. This time, all accounts (A, B, and C) returned "invalid user," and only a new account, D, which had never logged in before, was able to retrieve data successfully.

I also re-downloaded and applied the google-services.json file, and I repeatedly checked that there were no issues with the API key.

Could this mistake be the reason why non-new accounts are unable to retrieve the Email or Display Name properly? I have absolutely no idea what is causing this issue.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论