Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error Something went wrong, code: 10 #291

Open
mohamednagy opened this issue Jul 22, 2023 · 60 comments
Open

Getting error Something went wrong, code: 10 #291

mohamednagy opened this issue Jul 22, 2023 · 60 comments

Comments

@mohamednagy
Copy link

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

@sunda-amami
Copy link

I'm facing same issue.

@sunda-amami
Copy link

sunda-amami commented Aug 2, 2023

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.

@Diog0-0
Copy link

Diog0-0 commented Aug 2, 2023

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 ?

@stevegtdbz
Copy link

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

@Diog0-0
Copy link

Diog0-0 commented Aug 3, 2023

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 ?

@OnlinePage
Copy link

OnlinePage commented Aug 3, 2023

same issue here as well😔, @reslear

@sajjadalis
Copy link

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

@Diog0-0
Copy link

Diog0-0 commented Aug 4, 2023

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 ?

@OnlinePage
Copy link

OnlinePage commented Aug 6, 2023

finally after 43 hrs continuous real struggle, me fixed it😃🥳👯🎈🎉🎊

@stevegtdbz
Copy link

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

Please share the solution, big headaches here too..

@OnlinePage
Copy link

@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!

@sajjadalis
Copy link

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.

@stevegtdbz
Copy link

@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.

@OnlinePage
Copy link

@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
Copy link

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!!

@Diog0-0
Copy link

Diog0-0 commented Aug 8, 2023

@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...

@reslear
Copy link
Collaborator

reslear commented Aug 9, 2023

@OnlinePage please answer #202 (comment)

@riderx
Copy link
Contributor

riderx commented Aug 9, 2023

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

@stevegtdbz
Copy link

stevegtdbz commented Aug 10, 2023

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

@OnlinePage
Copy link

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
Copy link

@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

@SourabhKardile
Copy link

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:)

@matbravob
Copy link

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

@viktorisacenko
Copy link

For me, the problem solved by using all 3:

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

....

@itsalb3rt
Copy link

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

@OnlinePage
Copy link

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 😢.

@srivas-wrr
Copy link

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

@OnlinePage
Copy link

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 .

@elhombrej
Copy link

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!

@reslear
Copy link
Collaborator

reslear commented Mar 4, 2024

Maybe someone can add a PR faq section to the README with this problem?

@mumair4462
Copy link

mumair4462 commented Apr 2, 2024

i solve this error using the following steps:

  1. create firebase project
  2. enable email authentications
  3. add android app with sh1 key setup
  4. add web app
  5. install firebase or @codetrix-studio/capacitor-google-auth plugin
  6. go to google cloud console and open your firebase project which you created
  7. in Credentials > OAuth 2.0 Client IDs - copy web client

your component.ts code:

plateform: any;
constructor() {
if (!isPlatform('capacitor')) {
GoogleAuth.initialize({
clientId: '',
scopes: ['profile', 'email'],
});
}
}
ngOnInit() {
}

initialize() {
this.plateform.ready().then(() => { GoogleAuth.initialize() })
}

//call this ftn in html
async login() {

try {
  const user = await GoogleAuth.signIn();
  if (user) {
    console.log(user);
    alert("Success")
  }

} catch (error: any) {
  console.log(error);
  alert(JSON.stringify(error))

}

capacitor.conflt.ts

plugins: {
GoogleAuth: {
scopes: ['profile', 'email'],
clientId: "",
androidClientId: "",
serverClientId: "",
},

MainActivity.Java (import all packages)

@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerPlugin(GoogleAuth.class);
}

string.xml: "string name="server_client_id"></string">

index.html: "meta name="google-signin-client_id" content="" />

past google-services file download form firebase in android/app directory

REMEMBER ME IN YOUR PRAYERS

@dutypro
Copy link

dutypro commented Apr 13, 2024

I was stuck on this issue for a couple of days but managed to fix it with the help of this tutorial: https://www.youtube.com/watch?v=GwtpoWZ_78E&ab_channel=SimonGrimm

Essentially it looks like the issue is somehow at Google's end. You need to have both Android and Web credentials set up but will use the Web credentials in your app. There's not really any reason for the issue but it would appear it needs the SHA1 information for the Web to work... bizarre situation I know!

Hope it helps.

@shahidkarimi
Copy link

Only for God this thing might work.

@xbaldiq
Copy link

xbaldiq commented Apr 23, 2024

in my case, because i still in development, i need to use variant: DEBUG for SHA-1, and set it in android native OAuth 2.0 Client ID

i'm check it with: cd android && ./gradlew signInReport

@Raja-Malli-Dileep-Vadde
Copy link

Raja-Malli-Dileep-Vadde commented May 7, 2024

Actually, i am also totally confused about google signing in ionic app but, i got to know solution by several tries , i finally discovered that the debug keystore SHA1 only works in the emulator
Here,
#332 (comment)

@Raja-Malli-Dileep-Vadde
Copy link

Raja-Malli-Dileep-Vadde commented May 7, 2024

Only for God this thing might work.

Actually, i am also totally confused about google signing in ionic app but, i got to know solution by several tries, i finally discovered that the debug keystore SHA1 only works in the emulator
Here,
#332 (comment)

@Raja-Malli-Dileep-Vadde
Copy link

Raja-Malli-Dileep-Vadde commented May 7, 2024

Actually, i am also totally confused about google signing in ionic app but, i got to know solution by several tries , i finally discovered that the debug keystore SHA1 only works in the emulator
Here,
#332 (comment)

@Raja-Malli-Dileep-Vadde
Copy link

i'm check it with: cd android && ./gradlew signInReport

#332 (comment)

@Raja-Malli-Dileep-Vadde
Copy link

I was stuck on this issue for a couple of days but managed to fix it with the help of this tutorial: https://www.youtube.com/watch?v=GwtpoWZ_78E&ab_channel=SimonGrimm

Essentially it looks like the issue is somehow at Google's end. You need to have both Android and Web credentials set up but will use the Web credentials in your app. There's not really any reason for the issue but it would appear it needs the SHA1 information for the Web to work... bizarre situation I know!

Hope it helps.

#332 (comment)

@Raja-Malli-Dileep-Vadde
Copy link

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.

#332 (comment)

@sertal70
Copy link

sertal70 commented Jun 4, 2024

In my case, after having applied all suggestions collected here and in other related issue, the sign-in on android started to work when I used the web client id instead of android client id.

I can live with that, but... can anyone explain me why???

@lsantaniello
Copy link

I cant found my issue. Please help me {message: 'Something went wrong', code: '10'}

@arielhasidim
Copy link

@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!

As @OnlinePage mentioned, this was the problem for me also. See here for another explanation and with screenshots: #332 (comment)

@lsantaniello
Copy link

I am very frustrated. I've read so many messages and I can't resolve the problem. can someone help me? I'm willing to pay

@itsalb3rt
Copy link

@lsantaniello 🤙

@mumair4462
Copy link

I am experiencing considerable frustration as I have read numerous messages but have been unable to resolve my issue. I would appreciate any assistance, and I am willing to compensate for the help.

@isantaniello, could you please follow the steps outlined in this link:- #291 (comment)? Additionally, please verify your Capacitor version, as this issue might be related to a version mismatch. I encountered a similar problem, which was resolved after switching to Capacitor version 5 and following the specified steps.

@pedroshift
Copy link

For those getting problems about it, I recommend the mix between @OnlinePage solutions and this video: https://www.youtube.com/watch?v=GwtpoWZ_78E&ab_channel=SimonGrimm

It really makes understand what's going on in this process that for Android is quite weird!

In the end, my dev env works fine, but I am facing a problem only when sending it to PlayStore... I generated the signed APK using production fingerprint, and it runs smoothly on my device, but when generating the App bundle (.aab) using exactly same production fingerprint and sending it to PlayStore, my google login does not work anymore! :(

I can't really understand why .apk and .aab both signed with same production fingerprint work differently!
Someone had experience of publishing an App using it and can help me?

@pedroshift
Copy link

For those getting problems about it, I recommend the mix between @OnlinePage solutions and this video: https://www.youtube.com/watch?v=GwtpoWZ_78E&ab_channel=SimonGrimm

It really makes understand what's going on in this process that for Android is quite weird!

In the end, my dev env works fine, but I am facing a problem only when sending it to PlayStore... I generated the signed APK using production fingerprint, and it runs smoothly on my device, but when generating the App bundle (.aab) using exactly same production fingerprint and sending it to PlayStore, my google login does not work anymore! :(

I can't really understand why .apk and .aab both signed with same production fingerprint work differently! Someone had experience of publishing an App using it and can help me?

PlayStore problem fixed!!!
I created a new OAuth - Type Android, using Fingerprint of "App Signing Key Certificate" (SHA-1)

Summarizing:
-> At Google Cloud Console, create OAuth type: Web Application and use it to everything in your code!
(See video above to get all needed places... it's a lot)

-> Back to Google Cloud Console, create accordingly OAuth(s) type: Android, that won't be used anywhere by you but they need to be there, created and configured since Google needs it to proceed their validations and authorize Login.
To make it work properly on every environment, follow:

  • For Local/Simulator: debug.keystore SHA-1
    terminal: keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

  • Signed .APK: Upload key certificate SHA-1
    terminal: keytool -list -v -alias yourkey -keystore ~/path-to-your-key/yourkey
    then type your defined password and get SHA-1

  • Signed .AAB (Published on AppStore): App signing key certificate SHA-1
    Go to Google Play Console > Setup (sidebar menu) > App Sign

@MuscledGeek
Copy link

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😔

Worked like a charm. Thank you. In my case adding android app did it.

@kj1352
Copy link

kj1352 commented Aug 7, 2024

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😔

Worked like a charm. Thank you. In my case adding android app did it.

This worked for me. Thank you!

@ashraful61
Copy link

For me, the problem solved by using all 3:

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

....

Those three are the same ?

@mestefanell-rentman
Copy link

I had the same issue, the problem was solved by having an android client id (with the sha-1 fingerprint) and a regular web application client id in the google console credentials, while initializing the plugin use the web application client id, but in the capacitor config json I used the android client id.

Also make sure to test this using the corresponding certificates for that sha-1 fingerprint

@MalikHamza007
Copy link

Hello everyone,

i have solved the issue and it works perfecto even the app has gone into production.
Now here me out everyone except creating your own client ids from the google cloud console use firebase add your web ,android ,ios and enable google authentication from the fireBase this is the important step and then go to google cloud console select your firebase project from there and use the ids.Now our setup is ready and we come to code make sure that to test the app natively the build apk will be made from that system whose sha-1 fingerprints are added to firebase.

In the code initialize the pluggin in the page or component where your are using Google login and use your web client id for every configuration just add your android client id in the capacitor config ts or json. Trust me this will work.

For the android don't forget to add your permissions , your configuration in the strings.xml and registering the pluggin in the Main Activity Java.

If you need more Help I'll send you the zip file of my project just do npm i and your good to go
This is my mail '[email protected]'

@riderx
Copy link
Contributor

riderx commented Oct 3, 2024

The current IOS implementation will be refused in the store starting November, and the Android one in January.
If you want a more up-to-date alternative, I suggest using the one we made with my company:
https://github.com/Cap-go/capacitor-social-login/tree/main
We are a professional company and maintain +30 plugins
We made a special effort for documenting properly. The API is Almost the same.

@javiaa
Copy link

javiaa commented Oct 26, 2024

Hello! After struggling with the same problem I finally was able to make it work in simulator and android device.
I did it following this other thread: #220

But in summary,

  • In the code I have used the web_client_id everywhere (as many others point), for all web/server/android clientId properties. In my backend I have used only the web client id too.
  • In google cloud console I have had to crete two OAuth-Android entries with different the SHA-1 certificates
    1. For make it work in the emulator y have used SHA-1 from the local 'keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android'
    2. For make it work in the real Andorid device I have used the SHA-1 ceritficate that I have in Google Play Console under 'Test and release/Setup/App signing'
    3. Only just in case I have created a third Oauth-Android entry with the SHA-1 from my android.keystore used for the app signing in android studio, but with only this it was not working neither in the simulator or device.

I'm using capacitor 6.

@ashishc
Copy link

ashishc commented Jan 10, 2025

Is someone tracking the customer metrics? I can see for some end users they are still seeing this issue. Even though it worked for me.

@riderx
Copy link
Contributor

riderx commented Jan 10, 2025

CleanShot 2025-01-10 at 23 36 50
In case you didn't see the README, it's not recommended to use the plugin anymore, as the main maintainer is not reachable for more than a year.
@reslear is the only person who has write access and does not do native code.
So we agreed to add this note in the README to recommend capacitor-social-login he worked with me to help match the current requirements of this plugin.
We made our best effort to make the new plugin match all features, while having the new SDK ( who is a mess)
and the minimum changes possibles.
We removed only the 1000 ways of doing the same thing.
I wish we could archive it at least, but we can't...

@riderx
Copy link
Contributor

riderx commented Jan 11, 2025

I did a migration guide to simplify the migration for everyone: https://github.com/Cap-go/capacitor-social-login/blob/main/MIGRATION_CODETRIX.md

@riderx
Copy link
Contributor

riderx commented Jan 13, 2025

CleanShot 2025-01-13 at 18 08 46
We updated the README to make it explicit, do not use this plugin anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests