russmedia-digital / cordova-plugin-google-signin

Cordova Google SignIn
Apache License 2.0
11 stars 29 forks source link

Not work for me (ERROR MESSAGE 10) #9

Open miguelcas12 opened 2 years ago

miguelcas12 commented 2 years ago

I think I've done everything right, but when starting the session I get an ERROR 10.

image

I am using Cordova 11 with Android 11.0.0

pghoratiu commented 1 year ago

We recently started the process of upgrading to cordova-android 11, we will check it.

chriscant commented 1 year ago

I was getting error 10 when I had used the wrong client id. You need to use the server-side "Web application" Client ID as the CLIENT_ID for Android. I'm on cordova-android 10.1.2

zailleh commented 1 year ago

For anyone else that has this issue, use the client id found in google-services.json. client_type indicates it's a web client. Also be sure to remove the platform from your cordova directory before re-building as the client id value doesn't get updated between builds.

"other_platform_oauth_client": [
  {
    "client_id": "$$CLIENT_ID$$.apps.googleusercontent.com", /* use this */
    "client_type": 3
  },
redclouddrailan commented 10 months ago

Hi! when using the web application client id, I cannot seem to successfully verify it using the google verifyToken, the returned id_token's format is different to the ios, which i can verify successfully.

kwarnkham commented 6 months ago

{"status":"error","message":"10: "}

cordova 10 here

winniwoods commented 2 months ago

{"status":"error","message":"10: "}

cordova 12 here :(

SrFortes commented 2 months ago

{"status":"error","message":"10: "}

cordova 12. Any solution ?

winniwoods commented 2 months ago

After long experimentation, I was finally able to solve the problem. Important note: The plugin also works with Cordova 12 and Android 13!

README Improvement Suggestions

The README file could be improved to help even beginners (like myself) understand how to properly use the plugin.

My Solution Steps

  1. Create a New Project in Firebase and Google Cloud Console:

    • Create a new project in the Firebase console.
    • Create a new project in the Google Cloud Console.
    • Link both projects together.
  2. Create OAuth2 Credentials:

    • Create OAuth2 credentials for the web. The fields "Authorized JavaScript origins" and "Authorized redirect URIs" can remain empty.
    • Additionally, create OAuth2 credentials for Android. In my case, I had to do this twice: once for Debug and once for Production.
    • Update the google-services.json file in Firebase. You can find the required Client ID in the google-services.json under:
      "other_platform_oauth_client": [
      {
       "client_id": "$$CLIENT_ID$$.apps.googleusercontent.com", /* use this */
       "client_type": 3
      }
      ]
  3. Enter SHA-1 Keys:

    • Enter the SHA-1 keys in the Firebase console. In my case, I had to enter two keys: one for Android Production and one for Android Debug.
    • This was a stumbling block for me as I didn't know that need Web and Android Oauth2 Data.
  4. Enable Google Sign-In in Firebase:

    • In Firebase, go to Authentication > Sign-in method and enable Google.
  5. Correct Use of Installation Variables:

    • Ensure that you use the correct variables when installing the plugin:
      cordova plugin add https://github.com/russmedia-digital/cordova-plugin-google-signin --save --variable REVERSED_CLIENT_ID=myreversedclientid --variable CLIENT_ID=yourclientid
    • If you need to change the keys later, make sure to cleanly remove the plugin and reinstall it with the new keys.
    • Check that the correct Client ID is set in platforms/android/app/src/main/res/values/strings.xml.
  6. Fix Error in README:

    • In the README under "Example":
      cordova plugin add https://github.com/russmedia-digital/cordova-plugin-google-signin --save --variable REVERSED_CLIENT_ID="com.googleusercontent.apps.741002292512-79l1vjkim5tctosr07kcm61bb4frp7cr" --variable CLIENT_ID="741002292512-cs3emldkmt4vg5e1m9o6b3bpf8i6atfp.apps.googleusercontent.com"

      Remove the standalone "n" after cordova-plugin-google-signin.

After a week of intensive experimentation, I finally got it working. Another stumbling block was that I thought I had to implement some client keys in my config.xml, which was not the case.

I hope this description helps someone!

Good luck! 😊

I wrote this description in German and had it translated using ChatGPT.

SrFortes commented 2 months ago

After long experimentation, I was finally able to solve the problem. Important note: The plugin also works with Cordova 12 and Android 13!

README Improvement Suggestions

The README file could be improved to help even beginners (like myself) understand how to properly use the plugin.

My Solution Steps

  1. Create a New Project in Firebase and Google Cloud Console:

    • Create a new project in the Firebase console.
    • Create a new project in the Google Cloud Console.
    • Link both projects together.
  2. Create OAuth2 Credentials:

    • Create OAuth2 credentials for the web. The fields "Authorized JavaScript origins" and "Authorized redirect URIs" can remain empty.
    • Additionally, create OAuth2 credentials for Android. In my case, I had to do this twice: once for Debug and once for Production.
    • Update the google-services.json file in Firebase. You can find the required Client ID in the google-services.json under:
      "other_platform_oauth_client": [
      {
       "client_id": "$$CLIENT_ID$$.apps.googleusercontent.com", /* use this */
       "client_type": 3
      }
      ]
  3. Enter SHA-1 Keys:

    • Enter the SHA-1 keys in the Firebase console. In my case, I had to enter two keys: one for Android Production and one for Android Debug.
    • This was a stumbling block for me as I didn't know that need Web and Android Oauth2 Data.
  4. Enable Google Sign-In in Firebase:

    • In Firebase, go to Authentication > Sign-in method and enable Google.
  5. Correct Use of Installation Variables:

    • Ensure that you use the correct variables when installing the plugin:
      cordova plugin add https://github.com/russmedia-digital/cordova-plugin-google-signin --save --variable REVERSED_CLIENT_ID=myreversedclientid --variable CLIENT_ID=yourclientid
    • If you need to change the keys later, make sure to cleanly remove the plugin and reinstall it with the new keys.
    • Check that the correct Client ID is set in platforms/android/app/src/main/res/values/strings.xml.
  6. Fix Error in README:

    • In the README under "Example":

      cordova plugin add https://github.com/russmedia-digital/cordova-plugin-google-signin --save --variable REVERSED_CLIENT_ID="com.googleusercontent.apps.741002292512-79l1vjkim5tctosr07kcm61bb4frp7cr" --variable CLIENT_ID="741002292512-cs3emldkmt4vg5e1m9o6b3bpf8i6atfp.apps.googleusercontent.com"

      Remove the standalone "n" after cordova-plugin-google-signin.

After a week of intensive experimentation, I finally got it working. Another stumbling block was that I thought I had to implement some client keys in my config.xml, which was not the case.

I hope this description helps someone!

Good luck! 😊

I wrote this description in German and had it translated using ChatGPT.

Follow your steps, but I still keep getting error 10.