CapacitorGoogleAuth icon indicating copy to clipboard operation
CapacitorGoogleAuth copied to clipboard

Getting error Something went wrong, code: 10

Open mohamednagy opened this issue 2 years ago โ€ข 60 comments

I'm trying to use this package for google sign in. I'm always getting this error

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

I tried to follow the documentation as is, here is my configurations:

capacitor.config.json

{
  "appId": "io.ionic.nostashteeb",
  "appName": "Nos Tashteeb",
  "webDir": "dist",
  "bundledWebRuntime": false,
  "plugins": {
    "GoogleAuth": {
      "scopes": ["profile", "email"],
      "iosClientId": "",
      "clientId": "CLIENT_ID.apps.googleusercontent.com",
      "androidClientId": "CLIENT_ID.apps.googleusercontent.com",
      "serverClientId": "CLIENT_ID.apps.googleusercontent.com",
      "forceCodeForRefreshToken": true
    }
  }
}

strings.xml

<string name="server_client_id">CLIENT_ID.apps.googleusercontent.com</string>

MainActivity

registerPlugin(
                com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.class
        );

and then within my vue application using as

try {
const response = await GoogleAuth.signIn();
} catch (error) {

}

I created my client_id from the google cloud console and copied my SHA1 to the google cloud console but still always getting this error.

capacitor: ^5.1.0 @codetrix-studio/capacitor-google-auth: ^3.3.2

mohamednagy avatar Jul 22 '23 15:07 mohamednagy

I'm facing same issue.

sunda-amami avatar Aug 02 '23 03:08 sunda-amami

This error is the same as error #87.

This error code indicates an issue caused by the developer. Check if your client_id is valid. Verify that the fingerprint of the debug.keystore has been registered in the Firebase project settings. If it is not, redownload and replace the google-services.json file.

sunda-amami avatar Aug 02 '23 05:08 sunda-amami

i have the same problem, i really try so many things, can help me ?

my config.json :

 "plugins": {
    "GoogleAuth": {
      "scopes": ["profile", "email"],
      "androidClientId": "ANDROID_APP_clientid",
      "forceCodeForRefreshToken": true
    }
  },

strings.xml

<string name="server_client_id">CLIENT_ID.apps.googleusercontent.com</string>

i don't know if i need a other cliendID, i see some peoples say for use the web_client_id and not the android_app_client_id, but don't work too :/.

What i can do ?

Diog0-0 avatar Aug 02 '23 20:08 Diog0-0

I have exactly the same issue. It seems that google deprecated a module that this repo built on and cannot work anymore.

https://developers.google.com/identity/gsi/web/guides/migration

stevegtdbz avatar Aug 03 '23 07:08 stevegtdbz

in this case i think, dont have other manner to use in a hibryd app(capacitor with ionic) ? In this guide i only see java codes in gradle. Maybe exists some plugin ? like capacitors plugins or ionics components ?

Diog0-0 avatar Aug 03 '23 13:08 Diog0-0

same issue here as well๐Ÿ˜”, @reslear

OnlinePage avatar Aug 03 '23 19:08 OnlinePage

Same issue. banging my head against the wall for the last few hours. Thought I was doing something wrong.

sajjadalis avatar Aug 03 '23 22:08 sajjadalis

i think we can use the basic method maybe ? instead of using a plugin we can using the firebase method open in browser of phone ? I try to use the browser for this but the browser can't back to the app after the authentication, someboy know something about this ?

Diog0-0 avatar Aug 04 '23 02:08 Diog0-0

finally after 43 hrs continuous real struggle, me fixed it๐Ÿ˜ƒ๐Ÿฅณ๐Ÿ‘ฏ๐ŸŽˆ๐ŸŽ‰๐ŸŽŠ

OnlinePage avatar Aug 06 '23 08:08 OnlinePage

How? You managed to make it work on android device too?

Please share the solution, big headaches here too..

stevegtdbz avatar Aug 06 '23 09:08 stevegtdbz

@stevegtdbz ya ya in understand pal, my issue was my sha1 key was different than that i added on firebase for google auth. I am using google auth. Also ensure you have added androidClientId specifcally for android in your capacitor config file. I m pretty sure this will work for you!! See bascially what i understood is code error 10 is totally related developer side issue, I have seen number of people already using this and succeed using the this google auth. Also google identiy is diffrerent and current auth is still supported , so currently we don't need worry about migration!

OnlinePage avatar Aug 06 '23 12:08 OnlinePage

Has anyone else got it working with the purposed solution? This GoogleAuth plugin should work independently if I'm not mistaken. How Firebase SHA1 is related to this. I tried with Firebase, provided SHA1, but still the same error.

sajjadalis avatar Aug 06 '23 19:08 sajjadalis

@stevegtdbz ya ya in understand pal, my issue was my sha1 key was different than that i added on firebase for google auth. I am using google auth. Also ensure you have added androidClientId specifcally for android in your capacitor config file. I m pretty sure this will work for you!! See bascially what i understood is code error 10 is totally related developer side issue, I have seen number of people already using this and succeed using the this google auth. Also google identiy is diffrerent and current auth is still supported , so currently we don't need worry about migration!

Thanks for the response. The old google api seems to work only for api keys that generated before of july 22.

Check the warning message here https://developers.google.com/identity/sign-in/web/sign-in

For new keys, as far as i understand, it requires to implement gis.

stevegtdbz avatar Aug 07 '23 06:08 stevegtdbz

@stevegtdbz ya ya in understand pal, my issue was my sha1 key was different than that i added on firebase for google auth. I am using google auth. Also ensure you have added androidClientId specifcally for android in your capacitor config file. I m pretty sure this will work for you!! See bascially what i understood is code error 10 is totally related developer side issue, I have seen number of people already using this and succeed using the this google auth. Also google identiy is diffrerent and current auth is still supported , so currently we don't need worry about migration!

Thanks for the response. The old google api seems to work only for api keys that generated before of july 22.

Check the warning message here https://developers.google.com/identity/sign-in/web/sign-in

For new keys, as far as i understand, it requires to implement gis.

But my api keys are created a week agao๐Ÿค” and it's working.

OnlinePage avatar Aug 07 '23 08:08 OnlinePage

But yeah, the google is upgarding it's policy and auth process , so @reslear , we need to also upgrade with it in near future! Who knows when it completly stops working!!

OnlinePage avatar Aug 07 '23 08:08 OnlinePage

@OnlinePage can you send an example of code ? i tried all this things and dont work for me :/. I will try to see the keys again, but I already add my SHA1 in app, which key i need put in androidClientId ? You catch the key from google-services.json ? in this file have client_type 1 and client_type 3 i think...

Diog0-0 avatar Aug 08 '23 14:08 Diog0-0

@OnlinePage please answer https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues/202#issuecomment-1666532128

reslear avatar Aug 09 '23 12:08 reslear

Make it work on my side by using serverClientId with "client_type": 3 client_id ( the web one, not native one WTF)

riderx avatar Aug 09 '23 13:08 riderx

After many days of searching & troubleshooting, it finally worked for me too!

In my case, firebase is no needed.. i am just getting the "id_token" and sending it to my backend.. then i verify the token and grand access to my user.. so here is what followed:

1) Google console setup Create a web application

  • Set into "Authorized JavaScript origins" & "Authorized redirect URIs" -> http://localhost ( to be able to test from your browser too, just add your serve port like http://localhost:4200 )
  • On "Publishing status" set "in production"
  • Now get the web_cllient_id and use it below on each config.GOOGLE_CLIENT_ID reference below

Create an android application (i know make no sense)

  • Set Name & Package name.
  • For the SHA1 go to android studio and use this one keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

2) capacitor.config.ts

plugins: {
    GoogleAuth: {
      scopes: ['profile', 'email'],
      clientId: config.GOOGLE_CLIENT_ID,
      androidClientId: config.GOOGLE_CLIENT_ID,
      serverClientId: config.GOOGLE_CLIENT_ID,
    },
  },

3) Angular component

GoogleAuth.initialize({
      clientId: config.GOOGLE_CLIENT_ID,
      scopes: ['profile', 'email'],
})
async googleSignIn() {
    let googleUser = await GoogleAuth.signIn();
    //todo
}

** On android project have only registered the plugin, nothing else registerPlugin(com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.class);

@OnlinePage You had right! I also used a new key and worked fine! but i also found another one from an old project in case google decides to shut down the new ones (as per their warnings) :p

stevegtdbz avatar Aug 10 '23 06:08 stevegtdbz

After many days of searching & troubleshooting, it finally worked for me too!

In my case, firebase is no needed.. i am just getting the "id_token" and sending it to my backend.. then i verify the token and grand access to my user.. so here is what followed:

1) Google console setup Create a web application

  • Set into "Authorized JavaScript origins" & "Authorized redirect URIs" -> http://localhost to be able to test from your browser too, just add your serve port like http://localhost:4200
  • On "Publishing status" set "in production"
  • Now get the web_cllient_id and use it below on each config.GOOGLE_CLIENT_ID reference below

Create an android application (i know make no sense)

  • Set Name & Package name.
  • For the SHA1 go to android studio and use this one keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

2) capacitor.config.ts

plugins: {
    GoogleAuth: {
      scopes: ['profile', 'email'],
      clientId: conf.GOOGLE_CLIENT_ID,
      androidClientId: conf.GOOGLE_CLIENT_ID,
      serverClientId: conf.GOOGLE_CLIENT_ID,
    },
  },

3) Angular component

GoogleAuth.initialize({
      clientId: config.GOOGLE_CLIENT_ID,
      scopes: ['profile', 'email'],
})
async googleSignIn() {
    let googleUser = await GoogleAuth.signIn();
    //todo
}

** On android project have only registered the plugin, nothing else registerPlugin(com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.class);

@OnlinePage You had right! I also used a new key and worked fine! but i also found another one from an old project in case google decides to shut down the new ones (as their warnings) :p

Glad it worked !! ๐Ÿฅณ. Ahhh... Google and it's policies๐Ÿ˜”

OnlinePage avatar Aug 10 '23 06:08 OnlinePage

@OnlinePage can you send an example of code ? i tried all this things and dont work for me :/. I will try to see the keys again, but I already add my SHA1 in app, which key i need put in androidClientId ? You catch the key from google-services.json ? in this file have client_type 1 and client_type 3 i think...

i guess @stevegtdbz answer is guide for you

OnlinePage avatar Aug 10 '23 20:08 OnlinePage

ERROR Error: Uncaught (in promise): Error: Something went wrong Error: Something went wrong at returnResult (VM3:849) at Object.win.androidBridge.onmessage (VM3:824) at q (polyfills.ea3cb635cad86c66.js:1) at polyfills.ea3cb635cad86c66.js:1 at polyfills.ea3cb635cad86c66.js:1 at y (main.589666d56b13e81b.js:1) at ve (main.589666d56b13e81b.js:1) at v.invoke (polyfills.ea3cb635cad86c66.js:1) at Object.onInvoke (main.589666d56b13e81b.js:1) at v.invoke (polyfills.ea3cb635cad86c66.js:1) at M.run (polyfills.ea3cb635cad86c66.js:1) at polyfills.ea3cb635cad86c66.js:1

I tried everything still nothing is happening plz help me:)

SourabhKardile avatar Aug 16 '23 16:08 SourabhKardile

I solved it by using the SHA1 from the Android Studio Terminal when running this command "./gradlew signingReport" I got it from the google docs: https://developers.google.com/android/guides/client-auth

matbravob avatar Aug 22 '23 20:08 matbravob

For me, the problem solved by using all 3:

clientId: google_web_client_id,
androidClientId: google_web_client_id,
serverClientId: google_web_client_id,

....

viktorisacenko avatar Aug 27 '23 17:08 viktorisacenko

After many days of searching & troubleshooting, it finally worked for me too!

In my case, firebase is no needed.. i am just getting the "id_token" and sending it to my backend.. then i verify the token and grand access to my user.. so here is what followed:

1) Google console setup Create a web application

  • Set into "Authorized JavaScript origins" & "Authorized redirect URIs" -> http://localhost ( to be able to test from your browser too, just add your serve port like http://localhost:4200 )
  • On "Publishing status" set "in production"
  • Now get the web_cllient_id and use it below on each config.GOOGLE_CLIENT_ID reference below

Create an android application (i know make no sense)

  • Set Name & Package name.
  • For the SHA1 go to android studio and use this one keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

2) capacitor.config.ts

plugins: {
    GoogleAuth: {
      scopes: ['profile', 'email'],
      clientId: config.GOOGLE_CLIENT_ID,
      androidClientId: config.GOOGLE_CLIENT_ID,
      serverClientId: config.GOOGLE_CLIENT_ID,
    },
  },

3) Angular component

GoogleAuth.initialize({
      clientId: config.GOOGLE_CLIENT_ID,
      scopes: ['profile', 'email'],
})
async googleSignIn() {
    let googleUser = await GoogleAuth.signIn();
    //todo
}

** On android project have only registered the plugin, nothing else registerPlugin(com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.class);

@OnlinePage You had right! I also used a new key and worked fine! but i also found another one from an old project in case google decides to shut down the new ones (as per their warnings) :p

Work for me thanks! in my case I see I put the IOS client id on the serverClientId lol

itsalb3rt avatar Sep 20 '23 00:09 itsalb3rt

After many days of searching & troubleshooting, it finally worked for me too!

In my case, firebase is no needed.. i am just getting the "id_token" and sending it to my backend.. then i verify the token and grand access to my user.. so here is what followed:

1) Google console setup Create a web application

  • Set into "Authorized JavaScript origins" & "Authorized redirect URIs" -> http://localhost ( to be able to test from your browser too, just add your serve port like http://localhost:4200 )
  • On "Publishing status" set "in production"
  • Now get the web_cllient_id and use it below on each config.GOOGLE_CLIENT_ID reference below

Create an android application (i know make no sense)

  • Set Name & Package name.
  • For the SHA1 go to android studio and use this one keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

2) capacitor.config.ts

plugins: {
    GoogleAuth: {
      scopes: ['profile', 'email'],
      clientId: config.GOOGLE_CLIENT_ID,
      androidClientId: config.GOOGLE_CLIENT_ID,
      serverClientId: config.GOOGLE_CLIENT_ID,
    },
  },

3) Angular component

GoogleAuth.initialize({
      clientId: config.GOOGLE_CLIENT_ID,
      scopes: ['profile', 'email'],
})
async googleSignIn() {
    let googleUser = await GoogleAuth.signIn();
    //todo
}

** On android project have only registered the plugin, nothing else registerPlugin(com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.class);

@OnlinePage You had right! I also used a new key and worked fine! but i also found another one from an old project in case google decides to shut down the new ones (as per their warnings) :p

Work for me thanks! in my case I see I put the IOS client id on the serverClientId lol

Glad ๐Ÿ˜Š you got it worked!! Ahhhh! this Google playing with us developers ๐Ÿ˜ข.

OnlinePage avatar Sep 20 '23 00:09 OnlinePage

After many days of searching & troubleshooting, it finally worked for me too!

In my case, firebase is no needed.. i am just getting the "id_token" and sending it to my backend.. then i verify the token and grand access to my user.. so here is what followed:

1) Google console setup Create a web application

  • Set into "Authorized JavaScript origins" & "Authorized redirect URIs" -> http://localhost ( to be able to test from your browser too, just add your serve port like http://localhost:4200 )
  • On "Publishing status" set "in production"
  • Now get the web_cllient_id and use it below on each config.GOOGLE_CLIENT_ID reference below

Create an android application (i know make no sense)

  • Set Name & Package name.
  • For the SHA1 go to android studio and use this one keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

2) capacitor.config.ts

plugins: {
    GoogleAuth: {
      scopes: ['profile', 'email'],
      clientId: config.GOOGLE_CLIENT_ID,
      androidClientId: config.GOOGLE_CLIENT_ID,
      serverClientId: config.GOOGLE_CLIENT_ID,
    },
  },

3) Angular component

GoogleAuth.initialize({
      clientId: config.GOOGLE_CLIENT_ID,
      scopes: ['profile', 'email'],
})
async googleSignIn() {
    let googleUser = await GoogleAuth.signIn();
    //todo
}

** On android project have only registered the plugin, nothing else registerPlugin(com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.class);

@OnlinePage You had right! I also used a new key and worked fine! but i also found another one from an old project in case google decides to shut down the new ones (as per their warnings) :p

Thankyou Bro

srivas-wrr avatar Dec 28 '23 17:12 srivas-wrr

After many days of searching & troubleshooting, it finally worked for me too!

In my case, firebase is no needed.. i am just getting the "id_token" and sending it to my backend.. then i verify the token and grand access to my user.. so here is what followed:

1) Google console setup Create a web application

  • Set into "Authorized JavaScript origins" & "Authorized redirect URIs" -> http://localhost ( to be able to test from your browser too, just add your serve port like http://localhost:4200 )
  • On "Publishing status" set "in production"
  • Now get the web_cllient_id and use it below on each config.GOOGLE_CLIENT_ID reference below

Create an android application (i know make no sense)

  • Set Name & Package name.
  • For the SHA1 go to android studio and use this one keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

2) capacitor.config.ts

plugins: {
    GoogleAuth: {
      scopes: ['profile', 'email'],
      clientId: config.GOOGLE_CLIENT_ID,
      androidClientId: config.GOOGLE_CLIENT_ID,
      serverClientId: config.GOOGLE_CLIENT_ID,
    },
  },

3) Angular component

GoogleAuth.initialize({
      clientId: config.GOOGLE_CLIENT_ID,
      scopes: ['profile', 'email'],
})
async googleSignIn() {
    let googleUser = await GoogleAuth.signIn();
    //todo
}

** On android project have only registered the plugin, nothing else registerPlugin(com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.class);

@OnlinePage You had right! I also used a new key and worked fine! but i also found another one from an old project in case google decides to shut down the new ones (as per their warnings) :p

Thankyou Bro ๐Ÿ˜Ž Cool you figured it out .

OnlinePage avatar Dec 28 '23 17:12 OnlinePage

I had this problem and followed all steps from @stevegtdbz but did not work until i specified a difrent port on the front end rather than http://localhost, i changed it for http://localhost:8100 and worked!

elhombrej avatar Jan 27 '24 18:01 elhombrej

This error is the same as error #87.

This error code indicates an issue caused by the developer. Check if your client_id is valid. Verify that the fingerprint of the debug.keystore has been registered in the Firebase project settings. If it is not, redownload and replace the google-services.json file.

Signing the apk with the wrong fingerprint (keystore) resolved the issue for me. This error can have several reasons, check everything.

Saibotig avatar Mar 03 '24 08:03 Saibotig