Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to login once logged out. #159

Closed
abingeorgev opened this issue Jan 22, 2015 · 8 comments
Closed

Not able to login once logged out. #159

abingeorgev opened this issue Jan 22, 2015 · 8 comments

Comments

@abingeorgev
Copy link

I have implemented STTwitter in my application which uses many API's of the twitter. STTwitter was so easy to implement. Thanks guys for saving my time. But, now I have an issue. Am able to login, use every API. But after I logout, Am not able to login the next time. HTTP unauthorized error. While logouting I cleared the STTwitterAPI instance to nil. Still its not working. Please help me.

@nst
Copy link
Owner

nst commented Jan 22, 2015

So you instantiate and use a STTwitterAPI instance, set it to nil, instantiate another instance the very same way and it doesn't work?

This is very surprising. Can you provide a sample code demonstrating the issue?

@abingeorgev
Copy link
Author

- (void) presentLogin
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    if ([defaults objectForKey:@"oauthVerifier"] && [defaults objectForKey:@"oauthToken"] && [defaults objectForKey:@"oauthTokenSecret"])
    {
        TimelineViewController *tvc = [[TimelineViewController alloc] initWithNibName:@"TimelineViewController" bundle:nil];
        [self presentViewController:tvc animated:YES completion:nil];
    }
    else
    {
        AppDelegate_Phone *app = [UIApplication sharedApplication].delegate;
        [app resetSTTwitter];
        self.twitter = nil;
        self.twitter = app.STTwitter;
        WebViewController *webViewVC = [[WebViewController alloc]initWithNibName:@"WebViewController" bundle:nil];
        [[NSURLCache sharedURLCache] removeAllCachedResponses];
        [self presentViewController:webViewVC animated:YES completion:nil];
        [_twitter postTokenRequest:^(NSURL *url, NSString *oauthToken) {
            NSLog(@"-- url: %@", url);

            NSLog(@"-- oauthToken: %@", oauthToken);

            NSURLRequest *request = [NSURLRequest requestWithURL:url];
            [webViewVC.webView loadRequest:request];

        } authenticateInsteadOfAuthorize:NO
                        forceLogin:@(YES)
                        screenName:nil
                     oauthCallback:@"plainoauth://handleOAuthLogin"
                        errorBlock:^(NSError *error) {
                            NSLog(@"-- error: %@", error);
                        }];
    }
}

@abingeorgev
Copy link
Author

-(void)resetSTTwitter
{
   self.STTwitter = nil;
//    self.STTwitter.userName = nil;
//    self.STTwitter.bearerToken = nil;
//    self.STTwitter.oauthAccessToken = nil;
//    self.STTwitter.oauthAccessTokenSecret = @""; 
    self.STTwitter = [STTwitterAPI twitterAPIWithOAuthConsumerKey:OAUTH_CONSUMER_KEY
                                                   consumerSecret:OAUTH_CONSUMER_SECRET];
}

@nst
Copy link
Owner

nst commented Jan 22, 2015

In the iOS demo project, you can login with Safari several times in a raw, and each time the STTwitterAPI instance is created again, so I don't think that the issue comes from STTwitter.

Maybe you should try to make a minimal Xcode project with one single button testing only this case. Then if STTwitter doesn't work as expected, I'll be more than happy to fix it, but I need to be able to see what's wrong.

@nst
Copy link
Owner

nst commented Jan 23, 2015

Maybe the issue depends on the settings associated with the consumer tokens?

Can you try your app with "STTwitter iOS Demo" tokens?

@abingeorgev
Copy link
Author

I am getting the same response with your keys. Sometimes it get stuck at the URL https://twitter.com/intent/sessions. In the demo app, that URL never get called. The funny part is, if I use my consumer key and secret in the demo app, it works.

@nst
Copy link
Owner

nst commented Feb 12, 2015

Then it's an issue in your app and not STTwitter, so I close this issue.

@nst nst closed this as completed Feb 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants