cordova-plugin-googleplus
cordova-plugin-googleplus copied to clipboard
Google Logout not working
I am trying many times.Google logout not working
I have the same issue. This is my logout call:
window['plugins'].googleplus.logout(
function(msg) {
alert(msg);
},
function(err) {
alert(err);
}
)
I always recieve error code 2.
This is my setup:
Your system information:
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.4
Ionic App Lib Version: 2.1.2
Ionic App Scripts Version: 0.0.36
OS: Windows 8.1
Node Version: v6.6.0
cordova-plugin-googleplus 5.1.1 "Google SignIn"
@EddyVerbruggen
Hey @ayushbafna24 and @deb4g,
What do you mean by logout is not working? Is there an error coming back?
@sammuggPS I have the same issue. The logout call doesn't return the "logged out user" instead it returns the status code 2.
Is this when you run it on an emulator? Or on a device?
Please refer to this documentation for status code info: https://developers.google.com/android/reference/com/google/android/gms/common/api/CommonStatusCodes
This occurs when i run it on an android emulator
The installed version of Google Play services is out of date.
The calling activity should pass this error code to getErrorDialog(Activity, int, int)
to get a localized error dialog that will resolve the error when shown.
Constant Value: 2
Okay, that means you need to update your SDK and create a new emulator image. You may also need to remove then re-add this plugin.
I am testing on a android device and my SDK has already updated. I am also re-add these plugin 5 to 6 days.Many peoples has also checking these method.They are also facing these issue.
Sir Please solve these issue as soon as possible.
It gives me a error
Blocking connect
On 29 October 2016 at 01:34, Sam Muggleworth [email protected] wrote:
Okay, that means you need to update your SDK and create a new emulator image. You may also need to remove then re-add this plugin.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/300#issuecomment-257015380, or mute the thread https://github.com/notifications/unsubscribe-auth/ALj8Ny_JzzXIumfR838ZADs9fYzWcBWaks5q4lVlgaJpZM4Kb5kz .
It gives me error on Google Logout
Google SDK has updated
Uncaught exception from plugin
java.lang.IllegalStateException: blockingConnect must not be called on the UI thread at com.google.android.gms.common.internal.zzac.zza(Unknown Source) at com.google.android.gms.internal.zzqp.blockingConnect(Unknown Source) at nl.xservices.plugins.GooglePlus.signOut(GooglePlus.java:191) at nl.xservices.plugins.GooglePlus.execute(GooglePlus.java:81) at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:117) at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98) at org.apache.cordova.PluginManager.exec(PluginManager.java:133) at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59) at org.apache.cordova.CordovaBridge.promptOnJsPrompt(CordovaBridge.java:135) at org.apache.cordova.engine.SystemWebChromeClient.onJsPrompt(SystemWebChromeClient.java:124) at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:887) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4935) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) at dalvik.system.NativeStart.main(Native Method)
On 29 October 2016 at 10:22, Ayush Bafna [email protected] wrote:
I am testing on a android device and my SDK has already updated. I am also re-add these plugin 5 to 6 days.Many peoples has also checking these method.They are also facing these issue.
Sir Please solve these issue as soon as possible.
It gives me a error
Blocking connect
On 29 October 2016 at 01:34, Sam Muggleworth [email protected] wrote:
Okay, that means you need to update your SDK and create a new emulator image. You may also need to remove then re-add this plugin.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/300#issuecomment-257015380, or mute the thread https://github.com/notifications/unsubscribe-auth/ALj8Ny_JzzXIumfR838ZADs9fYzWcBWaks5q4lVlgaJpZM4Kb5kz .
I solved these issue by adding these code for Google Logout.Hello Guys please add these code on a GooglePlus.java
I can give you a Simple path for finding these
nl.xservices.plugins/GooglePlus.java
private void signOut() { if (this.mGoogleApiClient == null) { savedCallbackContext.error("Please use login or trySilentLogin before logging out"); return; }
this.mGoogleApiClient.connect();
Auth.GoogleSignInApi.signOut(this.mGoogleApiClient).setResultCallback(new
ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { if (status.isSuccess()) { savedCallbackContext.success("Logged user out"); } else { savedCallbackContext.error(status.getStatusCode()); }
}
});
On 29 October 2016 at 10:42, Ayush Bafna [email protected] wrote:
It gives me error on Google Logout
Google SDK has updated
Uncaught exception from plugin java.lang.IllegalStateException: blockingConnect must not be called on the UI thread at com.google.android.gms.common.internal.zzac.zza(Unknown Source) at com.google.android.gms.internal.zzqp.blockingConnect(Unknown Source) at nl.xservices.plugins.GooglePlus.signOut(GooglePlus.java:191) at nl.xservices.plugins.GooglePlus.execute(GooglePlus.java:81) at org.apache.cordova. CordovaPlugin.execute(CordovaPlugin.java:117) at org.apache.cordova. CordovaPlugin.execute(CordovaPlugin.java:98) at org.apache.cordova. PluginManager.exec(PluginManager.java:133) at org.apache.cordova. CordovaBridge.jsExec(CordovaBridge.java:59) at org.apache.cordova. CordovaBridge.promptOnJsPrompt(CordovaBridge.java:135) at org.apache.cordova.engine.SystemWebChromeClient.onJsPrompt( SystemWebChromeClient.java:124) at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:887) at android.os.Handler. dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4935) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run( ZygoteInit.java:1038) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) at dalvik.system.NativeStart.main(Native Method)
On 29 October 2016 at 10:22, Ayush Bafna [email protected] wrote:
I am testing on a android device and my SDK has already updated. I am also re-add these plugin 5 to 6 days.Many peoples has also checking these method.They are also facing these issue.
Sir Please solve these issue as soon as possible.
It gives me a error
Blocking connect
On 29 October 2016 at 01:34, Sam Muggleworth [email protected] wrote:
Okay, that means you need to update your SDK and create a new emulator image. You may also need to remove then re-add this plugin.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/300#issuecomment-257015380, or mute the thread https://github.com/notifications/unsubscribe-auth/ALj8Ny_JzzXIumfR838ZADs9fYzWcBWaks5q4lVlgaJpZM4Kb5kz .
@sammuggPS I did what you suggested. The error still occurs. Could there be another reason for this?
Okay, make sure your emulator image is one of the Google API ones. e.g. Google APIs Intel x86 Atom System Image
what is your error.I can solved your error
@sammuggPS I use Google API x86_64.
Make sure that you are using SDK Level 23 for your emulator. Cordova-android does not currently support 24 and up.
I working with @mlinderm1993, we just used two different accounts to answer, but we'll use this account from now on. Sorry for the confusion.
We followed your instruction as seen below, but the problem still occurs.
If I use the logout fuction
window.plugins.googleplus.logout(
function (msg) {
alert(msg); // do something useful instead of alerting
}
);
no alert occurs and I'm not sure, whether the logout worked. Login on the other hand is working fine and returns the requested scope.
We're pretty sure it's our emulator, who causing the trouble, since the alert works, when we run the app on a physical Galaxy S4.
You can change on GooglePlus.java
I am also facing these issue.but can solves these issue by changing these lines
nl.xservices.plugins/GooglePlus.java
private void signOut() { if (this.mGoogleApiClient == null) { savedCallbackContext.error("Please use login or trySilentLogin before logging out"); return; }
this.mGoogleApiClient.connect();
Auth.GoogleSignInApi.signOut(this.mGoogleApiClient).setResultCallback(new
ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { if (status.isSuccess()) { savedCallbackContext.success("Logged user out"); } else { savedCallbackContext.error(status.getStatusCode()); }
}
});
On 2 November 2016 at 16:36, deb4g [email protected] wrote:
I working with @mlinderm1993 https://github.com/mlinderm1993, we just used two different accounts to answer, but we'll use this account from now on. Sorry for the confusion.
We followed your instruction as seen below, but the problem still occurs.
If I use the logout fuction
window.plugins.googleplus.logout( function (msg) { alert(msg); // do something useful instead of alerting } );
no alert occurs and I'm not sure, whether the logout worked. Login on the other hand is working fine and return the requested scope correct.
We're pretty sure it's our emulator, who causing the trouble, since the alert works, when we run it on a physical Galaxy S4.
[image: avd] https://cloud.githubusercontent.com/assets/23123381/19925877/30c9911c-a0f2-11e6-9f9e-69b211123195.png [image: sdk_1] https://cloud.githubusercontent.com/assets/23123381/19925875/30c58b3a-a0f2-11e6-9f3d-158b0294e64c.png [image: sdk_2] https://cloud.githubusercontent.com/assets/23123381/19925876/30c7feec-a0f2-11e6-99e0-f1c624a893e4.png
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/300#issuecomment-257835095, or mute the thread https://github.com/notifications/unsubscribe-auth/ALj8NzH_cqkeBbIiufDbmfuAofAQLKzSks5q6G7NgaJpZM4Kb5kz .
@ayushbafna24 Thanks for the answer, but it didn't help.
I am trying many times.google silent not working.
On 21 December 2016 at 12:16, valgen [email protected] wrote:
To reproduce the bug on Android devices (not emulators) follow these steps:
- Open your App
- Perform the login
- Totally close the App (even from the background running Apps)
- Re-open your App
- Try to logout
- It will fail with this message: "Please use login or trySilentLogin before logging out"
This was my "dirty" solution.
window.plugins.googleplus.logout( function (msg) { console.error('Google logout success'); }, function (err) { console.error('Error logging out from Google: ' + err); window.plugins.googleplus.trySilentLogin( { }, function (obj) { console.error('Google trySilentLogin success'); //try logout again window.plugins.googleplus.logout( function (msg) { console.error('Google logout success'); }, function (err) { console.error('Error logging out from Google for the 2nd time: ' + err); } ); }, function (err) { console.error('Google trySilentLogin error: ' + err); } ); } );
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/300#issuecomment-268449623, or mute the thread https://github.com/notifications/unsubscribe-auth/ALj8N8idbagpAhwExqxaYmLCz3o4f4w2ks5rKMtJgaJpZM4Kb5kz .
I deleted my previous post because I wanted to clarify that after the first login I save some user data in localStorage so next time I re-open the app I really don't need to do the login or trySilentLogin again.
To reproduce the bug on Android devices (not emulators) follow these steps:
- Open your App
- Perform the login and save some user data in localStorage
- Totally close the App (even from the background running Apps)
- Re-open your App and check if the user data is still available in localStorage (this means no need to login again)
- Try to logout
- It will fail with this message: "Please use login or trySilentLogin before logging out"
This was my "dirty" solution.
window.plugins.googleplus.logout(
function (msg) {
console.error('Google logout success');
},
function (err) {
console.error('Error logging out from Google: ' + err);
window.plugins.googleplus.trySilentLogin(
{
},
function (obj) {
console.error('Google trySilentLogin success');
//try logout again
window.plugins.googleplus.logout(
function (msg) {
console.error('Google logout success');
},
function (err) {
console.error('Error logging out from Google for the 2nd time: ' + err);
}
);
},
function (err) {
console.error('Google trySilentLogin error: ' + err);
}
);
}
);
We are using [cordova-plugin-googleplus 5.1.1 "Google SignIn"] inside ionic framework application and encountered the same issue.
For us it worked, after locally modifying the GooglePlus.java class by wrapping the calls to signout(), trySilentLogin(), disconnect() methods inside an AsyncTask as shown below.
new AsyncTask<String, String, String>() { @Override protected String doInBackground(String... params) { signOut(); return null; } }.execute();
At the UI side, we are calling 'window.plugins.googleplus.disconnect()' inside a promise construct.
I encountered the same error in my application on my tablet device. I solved updating the Google Play Services using the Play Store. I discovered the solution here.
The installed version of Google Play services is out of date. The calling activity should pass this error code to getErrorDialog(Activity, int, int) to get a localized error dialog that will resolve the error when shown. Constant Value: 2
I hope this may be useful.
Hello, @ascatox, your solution doesn't helped me fixing that issue ! Is there any planned fix for thais issue or should we keep using @valgen's solution (using trySilentLogin before logout) ? Regards.
If you are not a developer.You can hire me as a developer.I can solve your issue
On 7 November 2017 at 20:56, Antonio Scatoloni [email protected] wrote:
@anouarchattouna https://github.com/anouarchattouna I'm sorry, but I'm not a developer involved in this project, I don't know anything about the planning to fix this issue. Regards.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/300#issuecomment-342517519, or mute the thread https://github.com/notifications/unsubscribe-auth/ALj8N6sHw1UjQuIfh-lcMbc-7sg-7nZCks5s0Ha9gaJpZM4Kb5kz .
@anouarchattouna did trySilentLogin work? im trying same solution but silentlogin return an error
@jaigtz88 I'm doing like this
this.googlePlus.trySilentLogin({}).then(res => {
this.googlePlus.logout().then(res => {
[...]
.catch(error => {
[...]
});
}).catch(error => {
this.googlePlus.disconnect().then(res => {
[...]
}).catch(error => {
[...]
});
[...]
});
@anouarchattouna Below is my code, i get error return "Error google disconnect". Any idea why?
this.googlePlus.logout() .then(res => console.log('success logout google')) .catch(error => { console.error('Error logging out from Google: ' + error); this.googlePlus.trySilentLogin({}) .then(res => { this.googlePlus.logout() .then(res => { console.error('Google logout success'); }) .catch(error => { console.error('Error logging out from Google for the 2nd time: ' + error); }); }) .catch(error => { this.googlePlus.disconnect() .then(res => { console.error('Google disconnect success'); }) .catch(error => { console.error('Error google disconnect'); }); }); });
@jaigtz88 the order is important : trySilentLogin
and then logout
, so your custom logout method should be like this :
protected userLogout(event) {
this.googlePlus.trySilentLogin({}).then(res => {
this.googlePlus.logout().then(res => {
[...]
.catch(error => {
// handle error
});
}).catch(error => {
this.googlePlus.disconnect().then(res => {
[...]
}).catch(error => {
// handle error
});
});
}
@anouarchattouna after applied that code, it catch an error at disconnect. For your information, i just use trySilentLogin only for that code, but still not working.
Updated: some device are working, only one not working. wierd
@anouarchattouna THANK YOU SO MUCH !!! It's really working on my app. My problem solved :')
:+1: :100:
As @jaigtz88 pointed out, in some cases even @anouarchattouna's approach with trySilentLogin()
does not work and throws an error when calling disconnect()
.
The steps to reproduce this issue in my case were the following:
- (mobile) login to google account in your app by calling
login()
- (desktop) open a browser and login to google account with your username and password
- (desktop) change account password
- (mobile) return to the app and try to logout with code suggested by @anouarchattouna
You will get a 4 error when trying to log out on a disconnect()
call.
So far, the best solution I have found is to simply ignore all errors for the disconnect()
call (I also add them to the log and send with analytics). It seems that the next time you call login()
everything works fine and you will be prompted for the updated password for the account.