bengottlieb / Twitter-OAuth-iPhone

An easy way to get Twitter authenticating with OAuth on iPhone
http://www.standalone.com
799 stars 155 forks source link

SA_OAuthTwitterController initWithEngine Bug #74

Open sveltema opened 13 years ago

sveltema commented 13 years ago

I came across this bug yesterday when using SA_OAuthTwitterController with an SA_OAuthTwitterEngine that has not finished the OAuthSetup.

In the init method :

- (id) initWithEngine: (SA_OAuthTwitterEngine *) engine andOrientation:(UIInterfaceOrientation)theOrientation {
    if (self = [super init]) {
....
        if (!engine.OAuthSetup) [_engine requestRequestToken];
.....       
        NSURLRequest            *request = _engine.authorizeURLRequest;
        [_webView loadRequest: request];
.....
}

if (!engine.OAuthSetup) the SA_OAuthTwitterEngine requests a token, however before the response can be had from Twitter, _engine.authorizeURLRequest is called. When authorizeURLRequest will then send an authorization request with a nil request token.

On my local version I hacked together a Notification to SA_OAuthTwitterEngine, and a requestToken check if (nil != engine.requestToken) to SA_OAuthTwitterController, so that the SA_OAuthTwitterController will only attempt [_webView loadRequest: request] until after the request token has been returned by Twitter.

I may be missing an initialization step somewhere down the line, but this fix "works for me" for now.

bengottlieb commented 13 years ago

I agree, this should be adjusted at some point. Thanks for pointing this out!

B

On May 26, 2011, at 8:39 PM, sveltema wrote:

I came across this bug yesterday when using SA_OAuthTwitterController with an SA_OAuthTwitterEngine that has not finished the OAuthSetup.

In the init method :

- (id) initWithEngine: (SA_OAuthTwitterEngine *) engine andOrientation:(UIInterfaceOrientation)theOrientation {
  if (self = [super init]) {
....
      if (!engine.OAuthSetup) [_engine requestRequestToken];
.....     
      NSURLRequest            *request = _engine.authorizeURLRequest;
      [_webView loadRequest: request];
.....
}

if (!engine.OAuthSetup) the SA_OAuthTwitterEngine requests a token, however before the response can be had from Twitter, _engine.authorizeURLRequest is called. When authorizeURLRequest will then send an authorization request with a nil request token.

Im local version I hacked together a Notification to SA_OAuthTwitterEngine, and a requestToken check if (nil != engine.requestToken) to SA_OAuthTwitterController, so that the SA_OAuthTwitterController will only attempt [_webView loadRequest: request] until after the request token has been returned by Twitter.

I may be missing an initialization step somewhere down the line, but this fix "works for me" for now.

Reply to this email directly or view it on GitHub: https://github.com/bengottlieb/Twitter-OAuth-iPhone/issues/74

Ben Gottlieb iM ben@standalone.com

andywei commented 13 years ago

Hi sveltema, I found this problem too, could you please share your fix code? Thanks a lot!

sveltema commented 13 years ago

Andy,

The fix was way too hacky across a couple frameworks, so I switched back to XAuth (I have no need for sending DM). It was a simple hack though. Just add a notification to the request token completion to notify SA_OAuthTwitterController to send the authorizeURLRequest and load the webview.

andywei commented 13 years ago

Hi Sveltema, Thanks a lot!

I may implement it later :)

2011-6-197:24 sveltema д

Andy,

The fix was way too hacky across a couple frameworks, so I switched back to XAuth (I have no need for sending DM). It was a simple hack though. Just add a notification to the request token completion to notify SA_OAuthTwitterController to send the authorizeURLRequest and load the webview.

Reply to this email directly or view it on GitHub: https://github.com/bengottlieb/Twitter-OAuth-iPhone/issues/74#issuecomment-1400250

Best Regards Andy

albertodebortoli commented 13 years ago

Hi Sveltema, can you just post the code to copy and paste in the project? This bug is pretty annoying for a lot of people. Thank you