Error when login with Facebook SDK — React Native

Crysfel Villa
2 min readJun 20, 2016

--

While working with react-native-fbsdk, I found this issue when I was trying to login into my app.

2016–06–19 22:57:21.717 [info][tid:com.facebook.react.JavaScript] { [Error: Login Failed]line: 3314,column: 20,sourceURL: ‘http://localhost:8081/index.ios.bundle?platform=ios&dev=true',framesToPop: 1,code: ‘FacebookSDK’,nativeStackIOS:[ ‘0 MyAwesomeApp 0x0000000101e69c46 RCTJSErrorFromCodeMessageAndNSError + 134’,‘1 MyAwesomeApp 0x0000000101dfffc9 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2242 + 137’,‘2 MyAwesomeApp 0x0000000101f0cc1e __71-[RCTFBSDKLoginManager _loginWithPermissions:resolver:rejecter:isRead:]_block_invoke + 142’,‘3 MyAwesomeApp 0x0000000101da078e -[FBSDKLoginManager invokeHandler:error:] + 148’,‘4 MyAwesomeApp 0x0000000101da188d __57-[FBSDKLoginManager validateReauthentication:withResult:]_block_invoke + 396’,‘5 MyAwesomeApp 0x0000000101d8ad12 -[FBSDKGraphRequestMetadata invokeCompletionHandlerForConnection:withResults:error:] + 146’,‘6 MyAwesomeApp 0x0000000101d9171a __82-[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:]_block_invoke + 142’,‘7 MyAwesomeApp 0x0000000101d91539 -[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:] + 1073’,‘8 MyAwesomeApp 0x0000000101d90f66 __64-[FBSDKGraphRequestConnection completeWithResults:networkError:]_block_invoke + 487’,‘9 CoreFoundation 0x0000000103818462 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114’,’10 CoreFoundation 0x0000000103817b52 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 194',’11 MyAwesomeApp 0x0000000101d90cdf -[FBSDKGraphRequestConnection completeWithResults:networkError:] + 667',’12 MyAwesomeApp 0x0000000101d900c3 -[FBSDKGraphRequestConnection completeFBSDKURLConnectionWithResponse:data:networkError:] + 893',’13 MyAwesomeApp 0x0000000101d8e2d9 __36-[FBSDKGraphRequestConnection start]_block_invoke_2 + 72',’14 MyAwesomeApp 0x0000000101d8b470 -[FBSDKURLConnection invokeHandler:error:response:responseData:] + 85',’15 MyAwesomeApp 0x0000000101d8b3e5 -[FBSDKURLConnection logAndInvokeHandler:response:responseData:] + 390',’16 MyAwesomeApp 0x0000000101d8b810 -[FBSDKURLConnection connectionDidFinishLoading:] + 136',’17 CFNetwork 0x000000010350ea88 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 69',’18 CFNetwork 0x000000010350ea2c -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 199',’19 CFNetwork 0x000000010350eb81 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 48',’20 CFNetwork 0x000000010337cfbe ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 104',’21 CFNetwork 0x000000010346a965 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 100',’22 libdispatch.dylib 0x000000010693d49b _dispatch_client_callout + 8',’23 libdispatch.dylib 0x000000010691f54b _dispatch_block_invoke + 716',’24 CFNetwork 0x00000001033691ac _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 24',’25 CoreFoundation 0x00000001037e8ee4 CFArrayApplyFunction + 68',’26 CFNetwork 0x00000001033690a5 _ZN19RunloopBlockContext7performEv + 137',’27 CFNetwork 0x0000000103368f5e _ZN17MultiplexerSource7performEv + 282',’28 CFNetwork 0x0000000103368d80 _ZN17MultiplexerSource8_performEPv + 72',’29 CoreFoundation 0x0000000103815a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17',’30 CoreFoundation 0x000000010380b95c __CFRunLoopDoSources0 + 556',’31 CoreFoundation 0x000000010380ae13 __CFRunLoopRun + 867',’32 CoreFoundation 0x000000010380a828 CFRunLoopRunSpecific + 488',’33 GraphicsServices 0x0000000107fbaad2 GSEventRunModal + 161',’34 UIKit 0x00000001052f6610 UIApplicationMain + 171',’35 MyAwesomeApp 0x0000000101d557af main + 111',’36 libdyld.dylib 0x000000010697192d start + 1',’37 ??? 0x0000000000000001 0x0 + 1' ],domain: ‘com.facebook.sdk.login’ }

I didn’t know why I was getting this error, but I noticed that it only happened when I was already logged-in and then I logged out.

The way I was doing the logout was wrong, because I was only removing the token from the redux state, user information and all data related to the session, but I was not actually logging out using the Facebook SDK.

The problem was that Facebook SDK was still keeping the previous session token, and when I was trying to login again I was getting this error, to solve this problem all I had to do was to call the logOut method from the LoginManager.

export function logout() {
LoginManager.logOut();
return {
type: LOGOUT,
};
}

I hope this could help someone else.

--

--

Crysfel Villa

I’m a Software Engineer! I love to write code and music, traveling, learning languages and cultures.