logout from Twitter in iPhone using OAuth+MGTwitterEngine Library

喜夏-厌秋 提交于 2019-12-18 04:23:32

问题


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..!!


回答1:


There is no sign out from Twitter OAuth/xAuth... you need to implement client side solution:

  1. 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"
  2. when signing out delete any related data stored (in this case the access token)

hope that will help




回答2:


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!




回答3:


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.




回答4:


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




回答5:


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];
    }



回答6:


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];



回答7:


You must delete your account in Twitter application which is in the Settings menu of your iPhone.



来源:https://stackoverflow.com/questions/4067837/logout-from-twitter-in-iphone-using-oauthmgtwitterengine-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!