Open lexorcist opened 14 years ago
Try both clearing the access token and -releasing your engine instance; then re alloc/init it.
That's what I've done but it still doesn't work :( without restarting the app you still have to select 'sign in as different user' to properly logout.
Are you storing the provided OAuth token? Are you clearing that out as well?
I don't think so; at the moment, when you select to login it just presents the view controller [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self] and that's it. Then, when you logout it does the following:
[_engine clearAccessToken]; [_engine release]; _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self]; _engine.consumerKey = kOAuthConsumerKey; _engine.consumerSecret = kOAuthConsumerSecret;
There's probably something really stupid I'm doing wrong, thanks for your replies!
You should be passed some data in -storeCachedTwitterOAuthData:forUsername:. Make sure to clear this out.
I took the -storeCachedTwitterOAuthData:forUsername from the OAuthTwitterDemo app, which stores the data in the defaults with the key 'authData' and in -clearAccessToken the data is replaced with an empty string.
To make sure it was cleared out I just added a method that removes that object-key pair from the defaults completely when the access token is cleared; it still doesn't work.
Just in case I didn't describe my problem very well (and it's actually working as it's meant to or something):
The only way to get the username/password text fields is to press 'Sign in as a different user' which is also on the same page. Is this right? Or is this not meant to happen?
Thanks
so if you clear out all this cached data, quit the app (real quit, not just send it to the background), you're still seeing the "Sign in as a different user" screen?
Sorry, I thought I had said - I'm trying to make it happen without closing the app? It works if you quit the app, but is there a way to do it without quitting the app?
If it works when you quit, then you're probably not clearing everything out; double check to make sure you are.
I have the same issue and I think that this is related to some "web session" embed in the UIWebView.
Did anybody got a solution to make this work ? Maybe injecting some JS to "click" on the logout link would do the job ?
BTW thanks for the contrib !
HI Friends..... I am using Twitter API oAuth for developing iphone application.... i am login successfully in my application using twitter credential.... but when i try to logout... its not working...
Please help me regarding this
Thanks Subrat Email-mailtosubrat@gmail.com
Hi all, I really hope someone figures this out! I haven't been able to crack it.
I guess I found the solution for this Logout issue
In MGTwitterEngine class, there is a method called -(BOOL)clearsCookie. By default, this one returns NO, preventing clean logout until the user terminates the app.
Implement this method to return YES. You can implement it in MGTwitterEngine class, or in SA_OAuthTwitterEngine.
Using -(BOOL)clearsCookie with -(void)clearAccessToken of SA_OAuthTwitterEngine can make sure the user to logout without terminating the app.
I still don't seem to be able to get this to work, anyone have the code that they are using to signout?
This is how I implemented petershine's solution (successfully):
_engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self];
_engine.consumerKey = OAuthConsumerKey;
_engine.consumerSecret = OAuthConsumerSecret;
[_engine setClearsCookies:YES];
[_engine clearAccessToken];
UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self]; if (controller) { [self presentModalViewController:controller animated: YES]; } else { // Take care of Twitter business here then release everything
[_engine clearAccessToken];
[_engine release];
_engine = nil;
}
You may not have to release _engine, but I haven't tested without releasing.
I'm using [engine clearAccessToken] to logout of twitter, and then releasing and reallocating the engine to avoid the 'page not found' error that was coming up when I did that.
However, when you go to sign in again the user is actually still logged in; you just have to select 'allow' or 'deny' and to login as a different user you have to select the 'sign in as different user' link.
Is there a way to sign out fully, so that once you select to logout, you have to put your username and password in again to login?