CapacitorGoogleAuth icon indicating copy to clipboard operation
CapacitorGoogleAuth copied to clipboard

Something went wrong, error code 10 on Android

Open lsantaniello opened this issue 1 year ago • 10 comments

I integrated plugin on my ionic capacitor app. On iOS, it works. On Android Device I always receve this error:

{"save":false,"callbackId":"29072639","pluginId":"GoogleAuth","methodName":"signIn","success":false,"error":{"message":"Something went wrong","code":"10"}}

I configured all as wiki but I can't solve.

I have some doubts:

  1. Downloaded from firebase console my google-services.json. Is it required? Where I need to save it?

  2. I can't have "capacitor.config.json" file. I have only capacitor.config.ts

  3. In google-service.json file there are several codes:

  4. What is "serverClientId"?

  5. What is the crrect SHA-1 to register at Android Console? a) That present in Google Play Console? b) Thant generate from command line (keytool -keystore MYKEYSTORE -list -v)?

My google-services.json file is:

{
  "project_info": {
    "project_number": "*******",
    "project_id": "myapp-c7381",
    "storage_bucket": "*******-c7381.appspot.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:359711685148:android:5db8f05cc8c23360433dd9",
        "android_client_info": {
          "package_name": "it.********"
        }
      },
      "oauth_client": [
        {
          "client_id": "359711685148-aaaaaaaaaaaaaaaaaa.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "it.gemarexpress",
            "certificate_hash": "dsadasdasdsadada"
          }
        },
        {
          "client_id": "359711685148-kkkk.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "***********"
        }
      ],
      "services": {
        "appinvite_service": {
          "other_platform_oauth_client": [
            {
              "client_id": "359711685148-xxxx.apps.googleusercontent.com",
              "client_type": 3
            },
            {
              "client_id": "359711685148-yyyy.apps.googleusercontent.com",
              "client_type": 2,
              "ios_info": {
                "bundle_id": "**********"
              }
            }
          ]
        }
      }
    }
  ],
  "configuration_version": "1"
}

My capacitor.config.ts

As "androidClientId" I used "client.oauth_client.client_id". The same of there is on Google Cloud Console, OAuth 2.0 Client IDs as "[Android client for it.gemarexpress (auto created by Google Service)]"

image

  plugins: {
    GoogleAuth: {
      scopes: ['profile', 'email'],
      iosClientId: "359711685148-xxx.apps.googleusercontent.com",
      androidClientId: "359711685148-yyy.apps.googleusercontent.com",
      serverClientId: 'xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com',
      forceCodeForRefreshToken: true,
    },
  }

lsantaniello avatar Jun 06 '24 09:06 lsantaniello

Maybe this will help: https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues/332#issuecomment-2145794691

arielhasidim avatar Jun 14 '24 10:06 arielhasidim

I tried but It doesn't work for me.

I integrated Google Oauth Sign In in my Ionic Capacitor App but I have an issue for Android Device only:

When the user clicks on the Google login button from the app, a popup appears to select the gmail account. Immediately afterwards the system goes into error and in the log I find this error:

{ "save": false, "callbackId": "21517523", "pluginId": "GoogleAuth", "methodName": "signIn", "success": false, "error": { "message": "Something went wrong", "code": "10" } }

I've read several posts and tried different solutions but I can't resolve the problem. I followed the following steps

  1. I deleted all fingerprints from Firebase Console for Android application

  2. I have deleted all references from Google Cloud Console Oauth 2.0 Client IDs for the Android application

  3. Generated SHA using windows shell command keytool -keystore my-jks-file-path -list -v

Certificate fingerprints: SHA1: 56:5D:38:F2:D0:XX:XX:XX:XX:XX:D7:FB:56:7A:A2:D4:B5:1B:D0:C5

  1. Add SHA certificate fingerprint from Firebase Console (Android Apps)

  2. Google creae automatically reference into Google Cloud Console Oauth 2.0 Client IDs (Android client for (auto created by Google Service))

  3. Downloaded google-services.json file-path

  4. Copied google-services.json file into my ionic app into .\android\app\google-services.json

  5. Rebuild App using keystore (the same used for generate SHA certificate fingerprints )

  6. Installed on my android device

lsantaniello avatar Jun 20 '24 09:06 lsantaniello

I'll pay for support

lsantaniello avatar Jun 20 '24 10:06 lsantaniello

Any update on this? I'm implementing this and just ran into this issue :(

jaderinoo avatar Jul 02 '24 21:07 jaderinoo

I added my app SHA-256 in Firebase and it is started working for web application

image

image

in android folder I executed following command in command prompt gradlew signInReport

and copy SHA1 to Firebase SHA certificate fingerprints and same I did for SHA-256. While debugging it is not working but after deployment it is working fine without any issue

srinivaspillalamarri avatar Jul 12 '24 10:07 srinivaspillalamarri

Just an update from me:

As mentioned in other threads, we should be using the web app key for Android. Additionally, the SHA-1 for each keystore and the Google Play Console all need to be included on the certs page in the Google Console.

Each type of build has a SHA-1 that needs to be available on the Google Console for sso to work on android. I recommend fetching the SHA-1 for the debug keystore, the generated keystore you use to sign your app, and the SHA-1 available on the Play Console. If set up correctly, the SSO should go through. If not, then the SHA-1 for the version you're running isn't available on the Google Console.

jaderinoo avatar Jul 12 '24 18:07 jaderinoo

Hi Have you got any solution for this issue?

Karthika-PJ avatar Jul 26 '24 05:07 Karthika-PJ

Yes! complete solution is around SHA-1 and SHA-256 But I guess this repository need more documentation. Version should be updated to redirection and callback function. Refer to my previous post https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues/371#issuecomment-2225292476

srinivaspillalamarri avatar Jul 26 '24 05:07 srinivaspillalamarri

same issue here after update to capacitor 6 detail is that firebase is not mirroring the sha1 to console.cloud when add the key

acosme avatar Aug 28 '24 15:08 acosme

✅ Google Login Fix for Android

To enable Google login on Android, follow these steps:

1. Create Two OAuth Client IDs in Google Cloud

Development:

  • Get the SHA-1 key from your local environment by running:
  • ./gradlew signingReport

Production:

  • Get the SHA-1 key from the Google Play Console:
  • Go to Your App → Test and Release (side menu) → App Integrity
  • Scroll down to Play App Signing
  • Click the settings icon next to “Play App Signing”
  • Copy the SHA-1 and use it for production.

2. Important Configuration Notes

  • You do not need to use these Client IDs anywhere else.
  • Copy the Web Client ID and add it to capacitor.config.ts: Remove androidClientId from capacitor.config.ts. Keep only:
     serverClientId: '<WEB_CLIENT_ID>',
     iosClientId: '<IOS_CLIENT_ID>'
    
  • Add the following entry to: android/app/src/main/res/values/strings.xml <string name="server_client_id">YOUR_WEB_CLIENT_ID</string>

3. Update MainActivity.java

Replace the file: android/app/src/main/java/com/{{appName}}/customer/MainActivity.java with the following:

package {{YOUR_BUNDLE_ID}};

import android.os.Bundle;

import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;
import com.getcapacitor.BridgeActivity;

public class MainActivity extends BridgeActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        registerPlugin(GoogleAuth.class);
    }
}

✅ After completing these steps, Google login should work properly on Android.

Rahulsingh-2001 avatar Aug 31 '25 10:08 Rahulsingh-2001