Q:

Twitter OAuth redirects to my callback url

I am trying to use OAuth to connect to twitter in my iphone app . I have setup everything and the login popup pops up, however after logging in, it redirects to my callback url. Tapping the cancel button simply reopens the login screen. How do I make a callback url to get the app to close the login screen and allow the user to send a tweet? Thanks in advance

A:

Replace the below Method in SA_OAuthTwitterViewController.m , it should solve your problem (Note, I got it from the issues reported on github page :) )
- (void) webViewDidFinishLoad: (UIWebView *) webView {
    _loading = NO;
    //[self performInjection];
    if (_firstLoad) {
        [_webView performSelector: @selector(stringByEvaluatingJavaScriptFromString:) withObject: @"window.scrollBy(0,200)" afterDelay: 0];
        _firstLoad = NO;
    } else {
        // This else clause modified to work with twitter apps that have the callback URL set: https://dev.twitter.com/apps/
        // Bug details: https://github.com/bengottlieb/Twitter-OAuth-iPhone/issues/79
        [_engine requestAccessToken];

        if ([_delegate respondsToSelector: @selector(OAuthTwitterController:authenticatedWithUsername:)])
            [_delegate OAuthTwitterController: self authenticatedWithUsername: _engine.username];
        [self dismissModalViewControllerAnimated:YES];
    }

    [UIView beginAnimations: nil context: nil];
    _blockerView.alpha = 0.0;
    [UIView commitAnimations];

    if ([_webView isLoading]) {
        _webView.alpha = 0.0;
    } else {
        _webView.alpha = 1.0;
    }
}

Hope it solves your problem ...

