bdbergeron / BDBOAuth1Manager

OAuth 1.0a library for AFNetworking 2.x
MIT License
100 stars 35 forks source link

Crash after aborted login attempt #9

Closed tomburns closed 10 years ago

tomburns commented 10 years ago

I've got a crash which I can reproduce using the following steps:

  1. Begin OAuth login process; app bounces to Safari.
  2. Switch back to app without completing login process
  3. Tap button to begin login process again.

This occurs even if I call deauthorize on the session manager before attempting to log in again. Is there another call I should be making before reattempting the authentication?

2014-01-02 11:45:58.338 Skein[76189:70b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x0201a5e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x01cd98b6 objc_exception_throw + 44
    2   CoreFoundation                      0x01fce9c2 -[__NSArrayI objectAtIndex:] + 210
    3   CoreFoundation                      0x02099608 -[NSArray objectAtIndexedSubscript:] + 40
    4   Skein                               0x0008eb40 -[NSDictionary(BDBOAuth1Manager) initWithQueryString:] + 640
    5   Skein                               0x0008e88b +[NSDictionary(BDBOAuth1Manager) dictionaryFromQueryString:] + 123
    6   Skein                               0x0008805a -[BDBOAuthToken initWithQueryString:] + 170
    7   Skein                               0x00087dcd +[BDBOAuthToken tokenWithQueryString:] + 141
    8   Skein                               0x0008d02c __94-[BDBOAuth1SessionManager fetchRequestTokenWithPath:method:callbackURL:scope:success:failure:]_block_invoke + 268
    9   Skein                               0x00074505 __72-[AFURLSessionManagerTaskDelegate URLSession:task:didCompleteWithError:]_block_invoke_280 + 213
    10  libdispatch.dylib                   0x02c8c7f8 _dispatch_call_block_and_release + 15
    11  libdispatch.dylib                   0x02ca14b0 _dispatch_client_callout + 14
    12  libdispatch.dylib                   0x02c8f75e _dispatch_main_queue_callback_4CF + 340
    13  CoreFoundation                      0x0207fa5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
    14  CoreFoundation                      0x01fc06bb __CFRunLoopRun + 1963
    15  CoreFoundation                      0x01fbfac3 CFRunLoopRunSpecific + 467
    16  CoreFoundation                      0x01fbf8db CFRunLoopRunInMode + 123
    17  GraphicsServices                    0x032919e2 GSEventRunModal + 192
    18  GraphicsServices                    0x03291809 GSEventRun + 104
    19  UIKit                               0x00d15d3b UIApplicationMain + 1225
    20  Skein                               0x00005f6d main + 141
    21  libdyld.dylib                       0x02f3370d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
signal %d, info %p, uapVoid %p
Program ended with exit code: 0
tomburns commented 10 years ago

Using the debugger to investigate a bit further, I've determined that during the second attempt to authenticate tokenWithQueryString:(NSString *)queryString is getting called with the queryString @"Invalid OAuth Request", which is obviously incorrect and causes the crash.

bdbergeron commented 10 years ago

Tom, thanks for all the debugging info. Sure makes it easier to try and track things down! Also, my apologies for just getting to this issue. Unfortunately, I can't seem to duplicate this at all on my end. Would you mind sharing what OAuth provider you're trying to authenticate with? There's a chance they're doing something that doesn't conform to the RFC in terms of the response on errors. Also, since you're getting the response @"Invalid OAuth Request" from the server, I'm lead to believe this is related to what I just fixed in Issue #7, in which the previous request token was not being cleared and being sent in the header when you call fetchRequestToken the second time.

tomburns commented 10 years ago

It looks like this (and the 2.1.x issue from yesterday) were both addressed in the latest version. Thanks so much!