CapacitorGoogleAuth icon indicating copy to clipboard operation
CapacitorGoogleAuth copied to clipboard

Always showing 10:Something Went Wrong error - Ionic5 Capacitor4 Android

Open gilzonme opened this issue 2 years ago • 50 comments

I am getting always 10:Something Went Wrong error while trying to login to google. Following are the steps I have done and my configurations/versions.

Configurations done in console : image

Capacitor.config.ts : image

What am I missing?

gilzonme avatar Aug 08 '22 03:08 gilzonme

I have same problem, using version 3.1.4, ionic 5 with capacitor 3. As reference, it seems to work in iOS devices and in browser, the error only occurs in Android device

Any idea?

josevavia avatar Aug 08 '22 15:08 josevavia

It works if you do the next steps:

  • capacitor: 3.5.1 , perhaps this works in v4
  • ionic: 5
  • CapacitorGoogleAuth: 3.1.4
  1. capacitor.config.ts
const config: CapacitorConfig = {
  ...,
  plugins: {
    GoogleAuth: {
      scopes: ['profile', 'email'],
      androidClientId: "YOUR_WEB_CLIENT_ID.apps.googleusercontent.com",
      iosClientId: "YOUR_IOS_CLIENT_ID.apps.googleusercontent.com",
      forceCodeForRefreshToken: true
    },
  },
};

The CLIENT_ID for ANDROID must be the WEB_CLIENT_ID otherwise it will not work

image

Google Cloud Console/Credentials

  1. Web client Authorized JS Origins

Add your localhost:port to the list image

  1. strings.xml

Add server_client_id string to the file with your WEB_CLIENT_ID

<string name="server_client_id">YOUR_WEB_CLIENT_ID.apps.googleusercontent.com</string>
  1. MainActivity.java

Import the plugin and use registerPlugin instead of init (init is deprecated)

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

public class MainActivity extends BridgeActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        this.registerPlugin(GoogleAuth.class);

        super.onCreate(savedInstanceState);
    }
}

This works for me!

CodeRevenge avatar Aug 10 '22 19:08 CodeRevenge

Maybe you´ll find that interesting: https://ionicframework.com/blog/announcing-capacitor-4-0/ New Google Policy will put some pressure to maintain this project by lifting capacitor support to version 4

walebey avatar Aug 14 '22 11:08 walebey

Hey @gilzonme, Are you using Firebase? I have the same problem and think it might be related to my Firebase configuration.

carsten-klaffke avatar Aug 23 '22 07:08 carsten-klaffke

Hey @gilzonme, Are you using Firebase? I have the same problem and think it might be related to my Firebase configuration.

It worked for me now.

Did you find the cause? How did you get it working?

carsten-klaffke avatar Aug 23 '22 07:08 carsten-klaffke

Same for me... all those solutions don't work :( Cap 4 Ionic 6

EugeneKruglei avatar Aug 25 '22 22:08 EugeneKruglei

Unable to find a Capacitor plugin to handle requestCode, trying Cordova plugins Sending plugin error: {"save":false,"callbackId":"120447529","pluginId":"GoogleAuth","methodName":"signIn","success":false,"error":{"message":"Something went wrong","code":"12500"}} 2022-08-26 01:39:28.301 3167-3167/io.lewapp.vocabulary D/Capacitor/AppPlugin: Firing change: true 2022-08-26 01:39:28.301 3167-3167/io.lewapp.vocabulary V/Capacitor/AppPlugin: Notifying listeners for event appStateChange 2022-08-26 01:39:28.301 3167-3167/io.lewapp.vocabulary D/Capacitor/AppPlugin: No listeners found for event appStateChange 2022-08-26 01:39:28.301 3167-3167/io.lewapp.vocabulary D/Capacitor: App resumed 2022-08-26 01:39:28.318 3167-3167/io.lewapp.vocabulary E/Capacitor/Console: File: http://localhost/vendor.js - Line 83313 - Msg: ERROR Error: Uncaught (in promise): Error: Something went wrong Error: Something went wrong at returnResult (http://localhost/:422:32) at Object.win.androidBridge.onmessage (http://localhost/:397:21)

EugeneKruglei avatar Aug 25 '22 22:08 EugeneKruglei

I got it running now by stepping back to a Capacitor 3 version of my code and the re-executed the Cap4 migration. Maybe there was a problem with Capacitor that got fixed in the last days, because I carefully tracked my code changes and didn't see anything that could've caused the GoogleAuth problems. Suspiciously, when GoogleAuth gave me that 10-error-code, my Facebook login didn't work as well. The Facebook login errored out because of a wrong hash. So I think that somehow with the Cap4 migration the hashing of security keys got broken and that caused the 10-error-code at GoogleAuth.

carsten-klaffke avatar Aug 26 '22 09:08 carsten-klaffke

@carsten-klaffke somehow the issue was solved... I kept all the same configs(recommended setup config as described by @CodeRevenge here... Just removed all testing virtual devices Re-added it again - TiramisuPrivacySandbox image And... At the first start again an error... I logged-in in PlayMarket on the emulator - it works! Tomorrow I'll try to test the app on a real device... Need to try clearing/resetting default settings...

EugeneKruglei avatar Aug 28 '22 22:08 EugeneKruglei

It works if you do the next steps:

  • capacitor: 3.5.1 , perhaps this works in v4
  • ionic: 5
  • CapacitorGoogleAuth: 3.1.4
  1. capacitor.config.ts
const config: CapacitorConfig = {
  ...,
  plugins: {
    GoogleAuth: {
      scopes: ['profile', 'email'],
      androidClientId: "YOUR_WEB_CLIENT_ID.apps.googleusercontent.com",
      iosClientId: "YOUR_IOS_CLIENT_ID.apps.googleusercontent.com",
      forceCodeForRefreshToken: true
    },
  },
};

The CLIENT_ID for ANDROID must be the WEB_CLIENT_ID otherwise it will not work

image

Google Cloud Console/Credentials

  1. Web client Authorized JS Origins

Add your localhost:port to the list image

  1. strings.xml

Add server_client_id string to the file with your WEB_CLIENT_ID

<string name="server_client_id">YOUR_WEB_CLIENT_ID.apps.googleusercontent.com</string>
  1. MainActivity.java

Import the plugin and use registerPlugin instead of init (init is deprecated)

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

public class MainActivity extends BridgeActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        this.registerPlugin(GoogleAuth.class);

        super.onCreate(savedInstanceState);
    }
}

This works for me!

This is still the solution in Capacitor 4

ludufre avatar Sep 01 '22 04:09 ludufre

On our side the underlying issue was that somehow the SHA1 of our app changed with capacitor 4 migration. We had to add the new fingerprint to the Android App settings in firebase console and then the login was working again.

Reference: https://stackoverflow.com/questions/49450140/google-signin-api-exception-10

mircoservices avatar Sep 07 '22 11:09 mircoservices

In addition to the WEB Client ID you MUST have the SHA-1 Android key in GCloud added in the OAuth credentials even though the Android client ID is never mentioned anywhere in the Capacitor Google Auth code.

One other thing I ran into was that the key didn't transfer correctly from the changes in the capacitor.config.ts file to the android files. Make sure you run ionic capacitor build android to do this.

I only have the

  1. clientId in capacitor.config.json
  2. (androidClientId in my capacitor.config.ts file). not sure if this one is used
  3. server_client_id in strings.xml
  4. clientId in the init code for the plugin (for Web platform)

All of them the web client ID value.

Joep-DDQ avatar Sep 13 '22 11:09 Joep-DDQ

Hello, @EugeneKruglei I am facing the same issue, the above suggestions didn't help me. I am using @ionic/[email protected], capacitor4.2.0, @codetrix-studio/[email protected]. Did you solve the Google Login issue?

timeisgolden avatar Sep 21 '22 20:09 timeisgolden

Same problem. Can someone suggest something else ?

I managed to resolve this issue deleting the android app I previously created in the overview page of my project in firebase and creating it again with the app id, sha1 and app name.

daniromome avatar Sep 26 '22 18:09 daniromome

The same issue... Using Capacitor 4

image

Also used android key and WebClient key

pratikbhalodiya avatar Sep 30 '22 10:09 pratikbhalodiya

Apaparently there is an error between the debug.keytore and the release.keystore. When I add the debug.keystore in the google console (OAuth 2.0 Client IDs - Android Client) and I build the grandle with this in android studio, everything works. But when I add the release.keystore in the google console , it only works for the web and not for android or ios. What is going on? This is very weird.

Can anyone help ?

I also had problems, but the video helped me. For me, the problem was that an "Authorised JavaScript sources" was missing in the gcp console.

https://www.youtube.com/watch?v=Ay9F6WHfnkU

renehauck avatar Nov 08 '22 14:11 renehauck

We had the same issue. We fixed it by setting the androidClientId to the server_client_id value.

Diffing 3.0.2 and 3.2.0 shows that the clientId was read from server_client_id and is now androidClientId.

In 3.0.2:

String clientId = this.getContext().getString(R.string.server_client_id);

became in 3.2.0

String clientId = getConfig().getString("androidClientId",
      getConfig().getString("clientId",
        this.getContext().getString(R.string.server_client_id)));

jeromebon avatar Nov 23 '22 16:11 jeromebon

Facing Same error on Release build only.

When building debug build on mobile and adding debug SHA-1 to google console received from android studio it works. But when release on playstore and adding SHA-1 from developer console it shows error 10. What exactly i am missing here?

what exactly is the javascript origin? i have added default one http://localhost:8100 as my origin.

Saqib92 avatar Mar 17 '23 08:03 Saqib92

When building debug build on mobile and adding debug SHA-1 to google console received from android studio it works. But when release on playstore and adding SHA-1 from developer console it shows error 10. What exactly i am missing here?

@Saqib92 I think your issue is different. The behavior you get is expected, since Google Play generates a different SHA-1. You should also find & and that to the console.

selcuk-sahin avatar Mar 22 '23 12:03 selcuk-sahin

When building debug build on mobile and adding debug SHA-1 to google console received from android studio it works. But when release on playstore and adding SHA-1 from developer console it shows error 10. What exactly i am missing here?

@Saqib92 I think your issue is different. The behavior you get is expected, since Google Play generates a different SHA-1. You should also find & and that to the console.

where can i find it in Google Play?

Saqib92 avatar Mar 22 '23 13:03 Saqib92

When building debug build on mobile and adding debug SHA-1 to google console received from android studio it works. But when release on playstore and adding SHA-1 from developer console it shows error 10. What exactly i am missing here?

@Saqib92 I think your issue is different. The behavior you get is expected, since Google Play generates a different SHA-1. You should also find & and that to the console.

where can i find it in Google Play?

There are multiple ways,

From Google Cloud Console: 1 - Go to Google Cloud Console and log in with your Google Sign-in account. 2- Select the related project from the top (this could be a firebase/google cloud project) 3- Search for API/s clients 4- From the left menu select Credentials 5- In this menu you should see list of autogenerated items under OAuth 2.0 Client IDs. Select the relevant client & you will see the SHA1 key here.

From the APK: 1- Download the APK from Google Play Store. This medium article might help. 2- Learn the SHA1 from this APK, you can use install & use keytool here. SO post

selcuk-sahin avatar Mar 22 '23 13:03 selcuk-sahin

When building debug build on mobile and adding debug SHA-1 to google console received from android studio it works. But when release on playstore and adding SHA-1 from developer console it shows error 10. What exactly i am missing here?

@Saqib92 I think your issue is different. The behavior you get is expected, since Google Play generates a different SHA-1. You should also find & and that to the console.

where can i find it in Google Play?

There are multiple ways,

From Google Cloud Console: 1 - Go to Google Cloud Console and log in with your Google Sign-in account. 2- Select the related project from the top (this could be a firebase/google cloud project) 3- Search for API/s clients 4- From the left menu select Credentials 5- In this menu you should see list of autogenerated items under OAuth 2.0 Client IDs. Select the relevant client & you will see the SHA1 key here.

From the APK: 1- Download the APK from Google Play Store. This medium article might help. 2- Learn the SHA1 from this APK, you can use install & use keytool here. SO post

looks like I already done almost same.

Saqib92 avatar Mar 22 '23 14:03 Saqib92

Someone with the same error still? I have set client id for android the same as fo web but always code 10 error. Onl yandroid do not work. web and iOS is fine

cihakmar avatar Apr 11 '23 12:04 cihakmar

Why do I need to use firebase to fix this error, I tried everything so far.. nothing works still errors .. 10

ProjectHammer avatar Apr 21 '23 09:04 ProjectHammer

MainActivity.java

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

Strings.xml added - Added web_cilent_id

Created the following - (but didn't use Andriod client id anywhere). image

It works for web, ios, but doesn't work for Android.

It gives the following error -- D/CompatibilityChangeReporter: Compat change id reported: 78294732; UID 10159; state: ENABLED D/Capacitor: Unable to find a Capacitor plugin to handle requestCode, trying Cordova plugins 147138663 D/Capacitor: Sending plugin error: {"save":false,"callbackId":"1887292","pluginId":"GoogleAuth","methodName":"signIn","success":false,"error":{"message":"Something went wrong","code":"10"}}

abhisant avatar Apr 28 '23 07:04 abhisant

MainActivity.java

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

Strings.xml added - Added web_cilent_id

Created the following - (but didn't use Andriod client id anywhere). image

It works for web, ios, but doesn't work for Android.

It gives the following error -- D/CompatibilityChangeReporter: Compat change id reported: 78294732; UID 10159; state: ENABLED D/Capacitor: Unable to find a Capacitor plugin to handle requestCode, trying Cordova plugins 147138663 D/Capacitor: Sending plugin error: {"save":false,"callbackId":"1887292","pluginId":"GoogleAuth","methodName":"signIn","success":false,"error":{"message":"Something went wrong","code":"10"}}

I think google deprecated use .. on google console code 10 had a message saying no longer supported.

ProjectHammer avatar Apr 28 '23 07:04 ProjectHammer

I am using google auth in ionic ,sign in with google popup is opening but its throwing error message: 'Something went wrong', code: '10'

sachinkannaujiya98 avatar Apr 29 '23 08:04 sachinkannaujiya98

Yes webview isn't supported in Auth anymore due to security, you can't handle the response from outside of the android unless you handle it somewhere else .. you'll have to handle the code inside androids Java..

ProjectHammer avatar Apr 29 '23 09:04 ProjectHammer