Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the bit you're missing is here, SA_OAuthTwitterEngine.m:103:</p> <pre><code> //This generates a URL request that can be passed to a UIWebView. It will open a page in which the user must enter their Twitter creds to validate - (NSURLRequest *) authorizeURLRequest { if (!_requestToken.key &amp;&amp; _requestToken.secret) return nil; // we need a valid request token to generate the URL OAMutableURLRequest *request = [[[OAMutableURLRequest alloc] initWithURL: self.authorizeURL consumer: nil token: _requestToken realm: nil signatureProvider: nil] autorelease]; [request setParameters: [NSArray arrayWithObject: [[[OARequestParameter alloc] initWithName: @"oauth_token" value: _requestToken.key] autorelease]]]; return request; } </code></pre> <p>You will have to "fake" this user login out yourself, I believe by sending twitter the login credentials as a separate request. It appears that the setUsername method you're calling is actually called as a post operation once a valid access token has been received. See SA_OAuthTwitterEngine.m:185</p> <pre><code>// // access token callback // when twitter sends us an access token this callback will fire // we store it in our ivar as well as writing it to the keychain // - (void) setAccessToken: (OAServiceTicket *) ticket withData: (NSData *) data { if (!ticket.didSucceed || !data) return; NSString *dataString = [[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease]; if (!dataString) return; if (self.pin.length &amp;&amp; [dataString rangeOfString: @"oauth_verifier"].location == NSNotFound) dataString = [dataString stringByAppendingFormat: @"&amp;oauth_verifier=%@", self.pin]; NSString *username = [self extractUsernameFromHTTPBody:dataString]; if (username.length &gt; 0) { [[self class] setUsername: username password: nil]; if ([_delegate respondsToSelector: @selector(storeCachedTwitterOAuthData:forUsername:)]) [(id) _delegate storeCachedTwitterOAuthData: dataString forUsername: username]; } [_accessToken release]; _accessToken = [[OAToken alloc] initWithHTTPResponseBody:dataString]; } </code></pre> <p>So the steps are as follows:</p> <ol> <li>Request request token</li> <li>Fake user login to twitter and get the pin value</li> <li>Set the pin on the engine</li> <li>Request access token</li> </ol> <p>You can see where SA_OAuthTwitterController parses the pin out of the webview content in SA_OAuthTwitterController.m:156</p> <pre><code>#pragma mark Webview Delegate stuff - (void) webViewDidFinishLoad: (UIWebView *) webView { NSError *error; NSString *path = [[NSBundle mainBundle] pathForResource: @"jQueryInject" ofType: @"txt"]; NSString *dataSource = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&amp;error]; if (dataSource == nil) { NSLog(@"An error occured while processing the jQueryInject file"); } [_webView stringByEvaluatingJavaScriptFromString:dataSource]; //This line injects the jQuery to make it look better NSString *authPin = [[_webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('oauth_pin').innerHTML"] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; if (authPin.length == 0) authPin = [[_webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('oauth_pin').getElementsByTagName('a')[0].innerHTML"] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; [_activityIndicator stopAnimating]; if (authPin.length) { [self gotPin: authPin]; } if ([_webView isLoading] || authPin.length) { [_webView setHidden:YES]; } else { [_webView setHidden:NO]; } } </code></pre> <p>hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload