cordova-plugin-googleplus
cordova-plugin-googleplus copied to clipboard
How we can manage REVERSED_CLIENT_ID for iOS and Android
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
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);
}
);
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?
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?
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)