简体   繁体   中英

Unable to login with Facebook on iOS (SDK can't build auth URL)

For no apparent reason, my fully functional app with "Login with Facebook" functionality stopped working yesterday.

I dived deep into the error and found that the auth URL can't be built for some reason internally, failing the whole process.

The problem arises from + (NSURL *)URLWithScheme:(NSString *)scheme host:(NSString *)host path:(NSString *)path queryParameters:(NSDictionary *)queryParameters error:(NSError *__autoreleasing *)errorRef method in FBSDKInternalUtility class.

In line 430, it tries to build the URL:

NSURL *URL = [[NSURL alloc] initWithString:[NSString stringWithFormat:
                                          @"%@://%@%@%@",
                                          scheme ?: @"",
                                          host ?: @"",
                                          path ?: @"",
                                          queryString ?: @""]];

I've stepped through the code. scheme , host , path , and queryString are all set. Though it returns nil instead of a URL. I've tried calling the method with an empty query string, and it actually built the URL. For some reason, queryString is causing the URL to be not built correctly.

Here is the queryString : (I've replaced my app ID with 123456789)

(lldb) po queryString ?auth_type=rerequest&client_id=123456789&default_audience=friends&display=touch&e2e={%22init%22%3A70747.196361124996}&fbapp_pres=1&redirect_uri=fb123456789%3A%2F%2Fauthorize%2F&response_type=token%2Csigned_request&return_scopes=true&scope=user_birthday%2Cemail%2Cuser_friends%2Cuser_photos&sdk=ios&sdk_version=4.39.0&state={%22challenge%22%3A%22yi8jE3mok79u9BheN8dzCMCviGY%253D%22%2C%220_auth_logger_id%22%3A%22329202ED-2F9B-4DBC-A191-E2C720D9779C%22%2C%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A%22sfvc_auth%22}

What might be causing this? It was working just a few days ago.

After getting the same error on simulator, I examined the changes to my app in more detail. It was the latest Facebook SDK (4.39). I ran a pod update to update some other pods, which also updated Facebook SDK from 4.38.1 to 4.39.

I reverted back to 4.38.1 and the problem went away. In other words, Facebook SDK 4.39 broke their own login functionality, practically rendering their own SDK useless.

Forcing to use older version as below fixed the issue:

pod 'FBSDKCoreKit', '~> 4.38.1'
pod 'FBSDKLoginKit', '~> 4.38.1'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM