简体   繁体   English

无法在iOS上使用Facebook登录(SDK无法建立身份验证URL)

[英]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. 没有明显的原因,我具有“使用Facebook登录”功能的功能齐全的应用程序昨天停止工作。

I dived deep into the error and found that the auth URL can't be built for some reason internally, failing the whole process. 我深入研究该错误,发现由于某种原因无法在内部构建身份验证URL,从而使整个过程失败。

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. 问题是由于+ (NSURL *)URLWithScheme:(NSString *)scheme host:(NSString *)host path:(NSString *)path queryParameters:(NSDictionary *)queryParameters error:(NSError *__autoreleasing *)errorRef方法在FBSDKInternalUtility类中。

In line 430, it tries to build the URL: 在第430行中,它尝试构建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. schemehostpathqueryString都已设置。 Though it returns nil instead of a URL. 虽然它返回nil而不是URL。 I've tried calling the method with an empty query string, and it actually built the URL. 我尝试用一​​个空的查询字符串调用该方法,它实际上建立了URL。 For some reason, queryString is causing the URL to be not built correctly. 由于某种原因, queryString导致URL构建不正确。

Here is the queryString : (I've replaced my app ID with 123456789) 这是queryString :(我用123456789替换了我的应用ID)

(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). 这是最新的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. 我运行了一个pod update来更新其他一些pod update ,这也将Facebook SDK从4.38.1更新到了4.39。

I reverted back to 4.38.1 and the problem went away. 我恢复到4.38.1,问题消失了。 In other words, Facebook SDK 4.39 broke their own login functionality, practically rendering their own SDK useless. 换句话说, Facebook SDK 4.39打破了自己的登录功能,实际上使自己的SDK无法使用。

Forcing to use older version as below fixed the issue: 强制使用以下旧版本解决了该问题:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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