4

enter image description hereI've been using the classic Ben Gottlieb Twitter Open Source project to create a twitter login for iPad.

My code to instantiate the engine and display the login controller is:

if (!_engine) {
        _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self];
        [_engine setConsumerKey:@"kConsumerKey"];
        [_engine setConsumerSecret:@"kConsumerSecret"];
    }

    if (![_engine isAuthorized]){
        UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self];
        if (controller){
            if ([controller respondsToSelector:@selector(setModalPresentationStyle:)] == YES) {
                controller.modalPresentationStyle = UIModalPresentationFormSheet;
            }
            [self presentModalViewController:controller animated:YES];
            return;
        }

    }

In addition, I set the URLS for SA_OAuthTwitterEngine to https:

self.requestTokenURL = [NSURL URLWithString: @"https://twitter.com/oauth/request_token"];
self.accessTokenURL = [NSURL URLWithString: @"https://twitter.com/oauth/access_token"];
self.authorizeURL = [NSURL URLWithString: @"https://twitter.com/oauth/authorize"];

and my TWITTER_DOMAIN in MGTwitterEngine.m has been changed to:

#define TWITTER_DOMAIN          @"api.twitter.com/1"

Running this code in the simulator for both iPhone and iPad works like a charm. HOWEVER, whenever I test this code on an iPad device, I'm thrown this error:

Whoa there! The request token for this page is invalid. It may have already been used, or expired because it is too old. Please go back to the site or application that sent you here and try again; it was probably just a mistake

(Screenshot attached).

Any suggestions on how to get the standard login screen to appear will be greatly appreciated

dpigera
  • 3,339
  • 5
  • 39
  • 60

2 Answers2

2

I had the same problem and tried Jeff's way. It didn't work either. For some unknown reason, check your time settings and set to automatically set the time. This worked for me.

Ramy Kfoury
  • 937
  • 5
  • 8
  • Perfect man, yes this was the case with me, if you have changed time of your iPhone then request token does not work, even i had tried creating new token at twitter etc.. – UMAR-MOBITSOLUTIONS Sep 24 '12 at 16:25
1

I ran into the same issue. What happens is that the request doesn’t get a request token. You can explicitly call that:

SA_OAuthTwitterEngine *myEngine;
[myEngine requestRequestToken];

Hope this helps!

Jeff Kelley
  • 19,021
  • 6
  • 70
  • 80