swift - 使用 Azure Facebook 身份验证时未调用 SFAuthenticationSession 完成处理程序
问题描述
我正在使用 Azure B2C 在我的应用程序上实现 Facebook 登录,我必须使用 SFAuthenticationSession 来执行此操作,因为 FB 不允许它在 WKWebView 内运行。
我基本上是在尝试使用从服务器端返回的 URL 实现 SFAuthenticationSession,如下所示:
https://companyName.b2clogin.com/companyName.onmicrosoft.com/oauth2/v2.0/authorize?client_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&nonce=xxxxxxx-xxxxx-xxxx-xxxxxx-xxxxxxxxxx&response_type=code&redirect_uri=https://myrul-qa.azurewebsites.net&response_mode=query&scope=offline_access%20openid%20xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx&state=xxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxx&domain_hint=facebook.com&p=B2C_1_SiUpIn
问题是,我的完成处理程序没有被调用。
我的代码基本上是这样的:
var authSession: SFAuthenticationSession?
func auth(url: URL) {
authSession?.cancel()
self.authSession = SFAuthenticationSession(url: url, callbackURLScheme: nil) { (url, error) in
# this completion here is not getting called
if error != nil { return }
UIApplication.shared.open(url!)
}
self.authSession?.start()
}
如果我尝试这种方式,使用 facebook URL 而不是我的 Azure B2C URL,则会调用完成:
func auth2() {
let appID = Constant.facebookId
var components = URLComponents()
components.scheme = "https"
components.host = "m.facebook.com"
components.path = "/v2.11/dialog/oauth"
let clientID = URLQueryItem(name: "client_id", value: appID)
let display = URLQueryItem(name: "display", value: "touch")
let redirectURI = URLQueryItem(name: "redirect_uri", value: "fb\(appID)://authorize/")
components.queryItems = [clientID, display, redirectURI]
self.authSession = SFAuthenticationSession(url: components.url!, callbackURLScheme: nil) { (url, _) in
UIApplication.shared.open(url!)
}
self.authSession?.start()
}
我希望可以使用带有 SFAuthenticationSession 的 Azure B2C 调用完成。
解决方案
推荐阅读
- python - 我想用matplotlib显示一个由tensorflow 2.0转换的灰度图
- python - 将列转换为 DateTime 时如何使用 Pandas .loc() 函数?
- forms - 输入带有密码管道的文本,ngModel 异常
- amazon-web-services - 将大型数据帧写入 S3 AWS 时出现内存错误
- python - opt.curve_fit 只有一个参数
- javascript - 如何操作带有附加了jquery的id属性的行
- sql - 使用查询创建 SQL XML
- c++ - 在成为指向基类的指针后如何保留对子类方法的使用?
- php - PHP / JSON:我如何知道 JSON 数据是否为空?
- java - Tomcat 在会话故障转移事件期间注销用户并重新启动