Open miguelcas12 opened 2 years ago
We recently started the process of upgrading to cordova-android 11, we will check it.
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
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
},
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.
{"status":"error","message":"10: "}
cordova 10 here
{"status":"error","message":"10: "}
cordova 12 here :(
{"status":"error","message":"10: "}
cordova 12. Any solution ?
After long experimentation, I was finally able to solve the problem. Important note: The plugin also works with Cordova 12 and Android 13!
The README file could be improved to help even beginners (like myself) understand how to properly use the plugin.
Create a New Project in Firebase and Google Cloud Console:
Create OAuth2 Credentials:
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
}
]
Enter SHA-1 Keys:
Enable Google Sign-In in Firebase:
Authentication
> Sign-in method
and enable Google
.Correct Use of Installation Variables:
cordova plugin add https://github.com/russmedia-digital/cordova-plugin-google-signin --save --variable REVERSED_CLIENT_ID=myreversedclientid --variable CLIENT_ID=yourclientid
platforms/android/app/src/main/res/values/strings.xml
.Fix Error in README:
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!
I wrote this description in German and had it translated using ChatGPT.
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
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.
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 thegoogle-services.json
under:"other_platform_oauth_client": [ { "client_id": "$$CLIENT_ID$$.apps.googleusercontent.com", /* use this */ "client_type": 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.
Enable Google Sign-In in Firebase:
- In Firebase, go to
Authentication
>Sign-in method
and enableCorrect 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
.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.
I think I've done everything right, but when starting the session I get an ERROR 10.
I am using Cordova 11 with Android 11.0.0