Reputation: 11
I'm implementing Facebook Login on my app using Azure B2C and I have to use SFAuthenticationSession to do this because FB doesn't allow it to run inside a WKWebView.
I'm basically trying to implement a SFAuthenticationSession with the URL that returns from my server side that is something like this:
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
The problem is, my completion handler is not getting called.
My code is basically this:
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()
}
If I try this way, using the facebook URL instead of mine Azure B2C URL the completion is getting called:
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()
}
I expect that the completion can be called using my Azure B2C with SFAuthenticationSession.
Upvotes: 1
Views: 197