Cordova Google Sign in Android: dabbling between error 10 and 12500

If anyone using Meteor Cordova for Android managed to get Google sign up to work in their apps, can they please help me. I’ve been struggling with this for a few days. I’ve installed EddyVerbruggen’s cordova googleplus plugin, but I cannot get this to work in a thousand years.

I’ve been through all the help documents and searched for related issues. Here are the general steps I took:

  • I generated a SHA1 code and created both an Android oauth client and a webclient in google developers console.
  • Then I used the webclientId and put it into the login object.
  • With the android app pointing towards my deployed app it receives either error 10 or error 12500

The problem lies in the SHA1 code undoubtedly. Can anyone give me guidance on this first step?

Which key do I need to make it work? This didn’t help: https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/243

Which keystore do I need to use? Im really at a loss here, I’ve tried all options I know of. Is anyone able to help me through teamviewer? Just to make the android sign up work in my app?

Bump… still need help

This comment right here on github says you need the latest SDK tools. However Cordova does not have support for any version above 25.2.0 and you run into issues. So, did anyone manage to get Google sign in working on their app Android app?

We have Google login/oauth working with Meteor 1.5.1 on both web and with our Android app using the standard atmosphere package google-oauth@1.2.4, no need to install EddyVerbruggen’s cordova plugin directly as google-oauth uses a forked version of that plugin.

Looks like you are following the correct steps to generate the Google OAuth client IDs, but this gist may help as well as these Google instructions. You will need to use Android SDK Tools v25.2.5 or earlier to build Android Cordova app with Meteor v1.5.1. However, if you can install the latest Meteor 1.5.2-beta.6 release you can then build with latest the Android SDK Tools v26.0.2 because of this pull request.

Login example code:

Meteor.loginWithGoogle({requestPermissions: "requested permissions", requestOfflineToken: true}, error => {
  if (error) {
    // handle error
  } else {
    // successful login!
  }
});
1 Like

Thanks for trying to help @skirunman. Where do you put the webClientId without the cordova plugin? Im still getting error code 10, so I think the SHA1 key is still wrong. How did you retrief the SHA1 key?

For Google OAuth for web you just need to use the Google OAuth 2.0 client ID. We store this and other config in our settings.json file something like this

  "oauth": {
    "google": {
      "clientId": {
        "web": "123456789012-abcdefghijklmnopqrstuvwxyz012345.apps.googleusercontent.com",
      },
      "secret": "123456abcdef789012ghijklmn",
      "loginStyle": "popup",
      "scope": [
        "https://www.googleapis.com/auth/userinfo.email",
        "https://www.googleapis.com/auth/userinfo.profile",
        "https://www.google.com/m8/feeds",
        "https://www.google.com/calendar/feeds",
        "https://www.googleapis.com/auth/gmail.readonly"
      ]
    },

and on Meteor bootup retrieve and store in database something like

import {Meteor} from 'meteor/meteor';
import {ServiceConfiguration} from 'meteor/service-configuration';

// Configure oauth
const oauthConfig = Meteor.settings.oauth;
if (! oauthConfig) {
  console.warn('No Meteor.settings.oauth.'); 
} else {

  const {oauth: {google: {clientId: {web: clientId}, ...oauthGoogle}}} = Meteor.settings;
  ServiceConfiguration.configurations.upsert({service: 'google'}, {$set: {...oauthGoogle, clientId}});
}

then login looks something like this

const {scope} = ServiceConfiguration.configurations.findOne({service: 'google'});

Meteor.loginWithGoogle({requestPermissions: scope, requestOfflineToken: true}, error => {
  if (error) {
    // handle error
  } else {
    // successful login!
  }
});

You don’t use a SHA1 key for web login. You just provide the authorized JavaScript origins (https://yourapp.com) and redirect URIs (https://yourapp.com/_oauth/google) as per Google documentation

For Android app the SHA1 key gets automatically built into app.

FYI, for iOS app you will need to add the “reverse client id” to your mobile-config.js file before building something like

App.configurePlugin('cordova-plugin-googleplus', {
  REVERSED_CLIENT_ID: 'com.googleusercontent.apps.123456789012-012345abcdefghijklmnopqrstuvwxyz'
});

PS You should also read the Meteor API docs for accounts

2 Likes

Thanks you so much @skirunman, it works!!! Fixing the JavaScript origins along with providing the webclient id on the serverside did the trick. I can’t believe I’ve been stuck on this for at least 7 days.

Great to hear! :wink:

Sorry to bother, I still have this same issue with the signed .apk. Error code 10 is coming back to haunt me in my dreams ;( Any clue what is might be?

I have no way to debug the signed apk, or is there?

You need to put your app SHA1 key on Google Developer Console entry of your product.

Its been resolved now. I didnt know what the SHA1 of my release was, so I signed with a new keystore. If you upload to the playstore with the wrong SHA1 key, it will tell you the correct one.