cordova-plugin-googleplus icon indicating copy to clipboard operation
cordova-plugin-googleplus copied to clipboard

How we can manage REVERSED_CLIENT_ID for iOS and Android

Open harishintimetec opened this issue 6 years ago • 4 comments

Hello Team,

I have installed the plugin with below command, ionic cordova plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=myreversedclientid

Here client id is different for iOS and Android platform on Google developer console. So how authentication will work for both the platforms? As we need to pass one client id while installing the plugin either it should be iOS or Android.

Please suggest me.

Thanks

harishintimetec avatar Sep 17 '18 15:09 harishintimetec

For anyone still trying to figure this out, if you are building an app for both Android and iOS, you have to use the Android reversed client id when you add the plugin. (Don't worry, even though we are using the Android client id, it will still work on iOS):

ionic cordova plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=reversedAndroidClientId

Also IMPORTANT note: when you call the plugin in your code, you must pass the web client id (NOT the Android client id):

window.plugins.googleplus.login(
    {
      'scopes': '... ',
      'webClientId': 'web client id', // Use the web client id, NOT the android client id
      'offline': true
    },
    function (obj) {
      alert(JSON.stringify(obj)); // do something useful instead of alerting
    },
    function (msg) {
      alert('error: ' + msg);
    }
);

dansterrett avatar Nov 26 '18 17:11 dansterrett

For anyone still trying to figure this out, if you are building an app for both Android and iOS, you have to use the Android reversed client id when you add the plugin. (Don't worry, even though we are using the Android client id, it will still work on iOS):

ionic cordova plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=reversedAndroidClientId

Also IMPORTANT note: when you call the plugin in your code, you must pass the web client id (NOT the Android client id):

window.plugins.googleplus.login(
    {
      'scopes': '... ',
      'webClientId': 'web client id', // Use the web client id, NOT the android client id
      'offline': true
    },
    function (obj) {
      alert(JSON.stringify(obj)); // do something useful instead of alerting
    },
    function (msg) {
      alert('error: ' + msg);
    }
);

@dansterrett Interesting... I've tried your method but couldn't manage to make it work. I'm using Ionic 3, though. Do you want to share your lib/dependencies?

jayinai avatar Dec 30 '18 15:12 jayinai

Hello, thanks for posting this. I had the same problem in my application (Ionic 3 for IOS and Anderoid) too and was able to solve it using this solution. I have a question: how can the IOS version work without using the IOS REVERSE CLIENT ID? Also, is the 'offline': true mandatory?

AleCat83 avatar Feb 25 '19 18:02 AleCat83

can anyone pls enlighten during install cordova plugin googleplus

=>ionic cordova plugin add cordova-plugin-googleplus --save –variable REVERSED_CLIENT_ID= xxxx

which ID should put as myreversedclientid ? as now we have both different client ID for IOS and Android (from console.developers.google)

brook18 avatar Jul 14 '20 14:07 brook18