I had made the twitter application using the OAuth and MGTwitterEngine Library. The login phase is working fine but I am facing problem in logout. I had referred all the post of logout for OAuth but it doesn't works. So can anyone suggest the perfect method for logout from the Twitter ...? OR What changes I have to make in the Library file for the logout..!!
7 Answers
Did anyone ever find the solution for this? If so, please post!
UPDATE: I figured it out. In the MGTwitterEngine.m, search for _clearCookies in initWithDelegate method. This is currently set to NO, change it to YES. In your action method for logging out the current user, call [_engine clearAccessToken]. Now run it, and voila, it works!

- 345
- 2
- 10

- 57
- 2
- 4
-
I had already tried with it but it seems not works fine for me. – Dishant Mar 01 '11 at 13:16
There is no sign out from Twitter OAuth/xAuth... you need to implement client side solution:
- persistently store the access token in the keychain or coredata (it never expires unless the user revoke your application from his/her account) when log in and use it in subsequent calls to twitter and " keeping the user signed in"
- when signing out delete any related data stored (in this case the access token)
hope that will help

- 869
- 6
- 12
I use this tutorial for integreate twitter to iOS app link
For logout I use next:
[_engine clearAccessToken];
_engine - this is instance of SA_OAuthTwitterEngine class.
You can call this method on your IBAction method.
Also need this method
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:@"authData"];
[defaults synchronize];

- 25,505
- 44
- 151
- 277
I dont know how to logout. But if you want the login screen every time, do one thing (i dont know this is the right way), delete the login specific data which the engine saves in Userdefaults.

- 356
- 1
- 3
- 14
I don't see it explicitly stated here, but I used the "clearAccessToken" function in the SA_OAuthTwitterEngine to "log out" the current user.

- 157
- 1
- 4
-
Oops, never mind. That just removes permission for the app to post to Twitter. User is still logged in :( – Jon Conner Jan 24 '11 at 22:12
Might be kinds of stupid, but this seems to work
- (IBAction)logout:(id)sender {
[_engine dealloc];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:@"authData"];
[defaults synchronize];
[self presentLoginView];
}

- 1,185
- 1
- 7
- 5
-
1Why did somebody downwoted? Seems the only thing working.. `[_engine clearAccessToken]; //or something similar don't recal now and [_engine clearCookies]; //works but then twitpic engine fails(i use twitpic to upload images to twitter)` @canzhiye thanks! – Lukas Apr 20 '12 at 07:20
You must delete your account in Twitter application which is in the Settings menu of your iPhone.

- 15,729
- 10
- 59
- 55

- 1