krishnalead / socialauth-android

Automatically exported from code.google.com/p/socialauth-android
0 stars 0 forks source link

SignOut - not working as expected #108

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Sign in using SocialAuthAdapter with any social network
2. Kill the app and run it again.
3. SocialAuthAdapter signout() method will not logout the user while 
SocialAuthAdapter authorize() method will automatically log in the user without 
asking the credentials.

What is the expected output? What do you see instead?
SocialAuthAdapter authorize() method should ask user for the credentials.

What version of the product are you using? On what operating system?
SocialAuth: 4.2
Android: 2.3.4

Please provide any additional information below.

Original issue reported on code.google.com by ikergar...@bilbomatica.es on 11 Jul 2013 at 12:01

GoogleCodeExporter commented 8 years ago
Please let me know how you are killing the app. Have you checked custom-ui 
example.

Original comment by vineet.a...@3pillarglobal.com on 17 Jul 2013 at 11:45

GoogleCodeExporter commented 8 years ago
Yes, I checked the custom-ui example and I think that my problem is related 
with the fact that I need to sign in and sign out the user in different 
activities and how I'm managing SocialAuthAdapter object.

I will try to explain the workflow:

'FirstActivity'
The first activity that is executed in the app. If the user is flagged as 
'logged' in the database he/she is redirected to the 'MainActivity', on the 
contrary if he/she is flagged as 'not logged' the user is able to sign in using 
SocialAuthAdapter in that activity.

Code:

public class FirstActivity extends SherlockActivity {

    private static SocialAuthAdapter socialAdapter = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (socialAdapter == null){
            socialAdapter = new SocialAuthAdapter(new ResponseListener());
        }
.....
.....

    public static SocialAuthAdapter getSocialAdapter() {
        return socialAdapter;
    }

'MainActivity'
Here the user has the option to log out. So we flag the user as 'not logged' in 
the database and retrieve the SocialAuthAdapter object from 'FirstActivity' to 
call signout method.

Code:
                        /**
             * SIGN OUT
             */
            try {           
                FirstActivity.getSocialAdapter().signOut(Provider.GOOGLEPLUS.toString());
            } catch (Exception e){
                // EMPTY
            }
            try {           
                FirstActivity.getSocialAdapter().signOut(Provider.FACEBOOK.toString());
            } catch (Exception e){
                // EMPTY
            }
            try {           
                FirstActivity.getSocialAdapter().signOut(Provider.TWITTER.toString());
            } catch (Exception e){
                // EMPTY
            }

So the 'strange' thing is that, if the user is flagged as 'logged' and he 
doesn't need to sign in (because he did it for example days ago) the signOut 
method fails (that's why I added the empty 'catchs') BUT strangely calling 
signIn after that does not ask the user for the credentials because it somehow 
remembers it.

Regards

Original comment by ikergar...@bilbomatica.es on 17 Jul 2013 at 12:31

GoogleCodeExporter commented 8 years ago
07-18 08:02:34.938: W/System.err(30403): java.lang.NullPointerException
07-18 08:02:34.938: W/System.err(30403):    at 
android.webkit.CookieSyncManager.createInstance(CookieSyncManager.java:96)
07-18 08:02:34.938: W/System.err(30403):    at 
org.brickred.socialauth.android.SocialAuthAdapter.signOut(SocialAuthAdapter.java
:662)
07-18 08:02:34.938: W/System.err(30403):    at 
com.myapp.fragments.menu.MenuFragment.onListItemClick(MenuFragment.java:114)
07-18 08:02:34.948: W/System.err(30403):    at 
android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
07-18 08:02:34.948: W/System.err(30403):    at 
android.widget.AdapterView.performItemClick(AdapterView.java:290)
07-18 08:02:34.948: W/System.err(30403):    at 
android.widget.ListView.performItemClick(ListView.java:3599)
07-18 08:02:34.948: W/System.err(30403):    at 
android.widget.AbsListView$PerformClick.run(AbsListView.java:1838)
07-18 08:02:34.958: W/System.err(30403):    at 
android.os.Handler.handleCallback(Handler.java:587)
07-18 08:02:34.958: W/System.err(30403):    at 
android.os.Handler.dispatchMessage(Handler.java:92)
07-18 08:02:34.958: W/System.err(30403):    at 
android.os.Looper.loop(Looper.java:130)
07-18 08:02:34.968: W/System.err(30403):    at 
android.app.ActivityThread.main(ActivityThread.java:3844)
07-18 08:02:34.968: W/System.err(30403):    at 
java.lang.reflect.Method.invokeNative(Native Method)
07-18 08:02:34.968: W/System.err(30403):    at 
java.lang.reflect.Method.invoke(Method.java:507)
07-18 08:02:34.968: W/System.err(30403):    at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-18 08:02:34.968: W/System.err(30403):    at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-18 08:02:34.978: W/System.err(30403):    at 
dalvik.system.NativeStart.main(Native Method)

This is the exception 'singOut' method throws (which I could understand since I 
don't use SocialAuthAdapter 'signIn' if the user is already logged in my 
database) but then, as explained above, when I call 'signIn' the user is 
automatically logged without filling the credentials.

Regards

Original comment by ikergar...@bilbomatica.es on 18 Jul 2013 at 6:07

GoogleCodeExporter commented 8 years ago
Thanks we are checking an d let you know soon

Original comment by vineet.a...@3pillarglobal.com on 19 Jul 2013 at 8:31

GoogleCodeExporter commented 8 years ago

Original comment by vineet.a...@3pillarglobal.com on 19 Jul 2013 at 8:32

GoogleCodeExporter commented 8 years ago
I'm trying to use SocialAuthAdapter.signOut similarly like ikergar is 
describing - from different Activity. It looks like this problem is Context 
related. This is the stack trace after failing to singOut:

FATAL EXCEPTION: main
java.lang.IllegalArgumentException: Invalid context argument
at android.webkit.CookieSyncManager.createInstance(CookieSyncManager.java:86)
at 
org.brickred.socialauth.android.SocialAuthAdapter.signOut(SocialAuthAdapter.java
:662)

Original comment by tpbar...@gmail.com on 20 Aug 2013 at 12:17

GoogleCodeExporter commented 8 years ago
The problem is, that the SocialAuthAdapter context parameter is set only after 
calling enable and authorize methods. I suggest, to add context parameter to 
signOut method, because signOut should not depend on previous enable/authorize 
methods.

Original comment by tpbar...@gmail.com on 20 Aug 2013 at 12:34

GoogleCodeExporter commented 8 years ago
I am facing a similar problem to ikergars, I need to sign the user out in a 
different activity. Has there been any update on this front? Thanks.

Original comment by sujay.ve...@gmail.com on 8 Jan 2014 at 4:18

GoogleCodeExporter commented 8 years ago
facing a similar problem .any updates?

Original comment by ftechnol...@gmail.com on 25 Feb 2014 at 5:05

GoogleCodeExporter commented 8 years ago
I am facing similar problems.

Original comment by rugonlin...@gmail.com on 25 Feb 2014 at 5:37

GoogleCodeExporter commented 8 years ago
I am also facing same issue... need some solution ASAP pls.

Original comment by srini...@savinirs.com on 13 Mar 2014 at 1:54

GoogleCodeExporter commented 8 years ago
Please download latest jar we have fixed this issue.

http://sourceforge.net/projects/socialauth-android/files/

Original comment by vineet.a...@3pillarglobal.com on 24 Mar 2014 at 1:09

GoogleCodeExporter commented 8 years ago
Still fetching the same issue.

Original comment by mukesh14...@gmail.com on 8 May 2014 at 1:22

GoogleCodeExporter commented 8 years ago
I am also getting the same issue. i have used latest library but still issue 
not resolved.

Original comment by isplbbd...@gmail.com on 9 May 2014 at 5:13

GoogleCodeExporter commented 8 years ago
I found bug fix for signOut in latest updates of this library in the Changelog. 
I have try it, but I am also getting same problem. SignOut was unsuccessful and 
return error (NullpointerException). 

Please fix it correctly and give some example use.

Original comment by ikhsanud...@gmail.com on 9 May 2014 at 6:26

GoogleCodeExporter commented 8 years ago
In SocialAuthAdapter  signOut(Context ctx, String providerName) function put 
these lines

if (providerName != null) {
            if (socialAuthManager == null) {
                socialAuthManager = new SocialAuthManager();
                try {
                    loadConfig(ctx);
                } catch (Exception e) {
                    Log.d("SocialAuthAdapter", "Could not load configuration");
                }
            }

before 

if (socialAuthManager.getConnectedProvidersIds().contains(providerName)) 
socialAuthManager.disconnectProvider(providerName);

Solved it for me.

Original comment by krok...@gmail.com on 3 Jul 2014 at 9:20

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Thanks a lot!!!!! Your method works well....But you have to be more specific 
about the version of the socialauth-android used because the signout method 
that u have used can be found only in the latest version....So next time u post 
a solution pls be more specific...Once again...thanks a lot....

Original comment by Goksvers...@gmail.com on 15 Jul 2014 at 10:41

GoogleCodeExporter commented 8 years ago
Issue still occurs in version 3.2

Original comment by SzZzS2...@gmail.com on 31 Jul 2014 at 8:05

GoogleCodeExporter commented 8 years ago
This issue is not resolved as of ver 4.6. anyone with a workaround?

Original comment by kuriandungu@googlemail.com on 16 Sep 2014 at 7:35

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Managed a workaround of sorts by calling authorize then calling signout so that 
the last statement that is run is signout meaning that next time you use 
authorize it would have been previously signed out.

Below is a snippet of what I did and that's working. (Sort of) it will verify 
the existing account but when user taps a second time they can enter new 
accounts. It can be irritating for the user.

    AdapterSocialAuth = new SocialAuthAdapter(new ResponseListener());
        Try {
            if (strProvider.contains("google")) {
                    AdapterSocialAuth.addConfig(SocialAuthAdapter.Provider.GOOGLEPLUS, "yourstringEtc.googleusercontent.com", "yourOtherCode",https://www.googleapis.com/auth/userinfo.profile,https://www.googleapis.com/auth/userinfo.email");

                    AdapterSocialAuth.addCallBack(SocialAuthAdapter.Provider.GOOGLEPLUS,"https://YourWebsite/svc/auth/oauth2callback");

                    AdapterSocialAuth.authorize(activity_change_email.this, SocialAuthAdapter.Provider.GOOGLEPLUS); //your activities context comes in here. mine is called activity_change_email.

                    AdapterSocialAuth.signOut(activity_change_email.this,SocialAuthAdapter.Provider.GOOGLEPLUS.toString()); //here i run signOut knowing that it wont throw an NPE because authorize forces
                    //the required stuff to load. hence it wont be null

                    }
        } catch (Exception e) {
                Toast.makeText(this, "Error Occured " + e.getMessage(), Toast.LENGTH_LONG).show();
                e.printStackTrace();
         }

Original comment by kuriandungu@googlemail.com on 16 Sep 2014 at 8:41

GoogleCodeExporter commented 8 years ago
i can still reproduce the bug, the log out only works if user log out 
immediately after logged in, which makes not much sense... After user restart 
the Activity I have to re-login before try to log out, otherwise i will get a 
NPE. Although there is no log in dialog, but for some special case, like the 
token is just expired, user will see a login dialog when they click "log out" 
button...

The best solution is the fix of #16 krok...@gmail.com

Original comment by cn1...@gmail.com on 4 Jan 2015 at 4:03

GoogleCodeExporter commented 8 years ago
i want to logout from another activity .. how to implement that ?

Original comment by pal...@bugletech.com on 26 Feb 2015 at 10:40

GoogleCodeExporter commented 8 years ago
please help me
when i implemented in same activity it's working fine,
I want to logout from another activity,iam getting this exception:
04-30 19:46:17.934: E/Exception Entered(3494): java.lang.NullPointerException: 
Attempt to invoke virtual method 'boolean 
org.brickred.socialauth.android.SocialAuthAdapter.signOut(android.content.Contex
t, java.lang.String)' on a null object reference10

Original comment by saikiran...@gmail.com on 30 Apr 2015 at 2:28