I am using the MSAL library for authentication, and after successful authentication, I am setting cookies for the WKWebView to run the application. However, it does not work.
I am using following code snippet for cookies setup :
DispatchQueue.main.async {
var tokenCookieProperty: [HTTPCookiePropertyKey: Any] = [
HTTPCookiePropertyKey.domain: "*",
HTTPCookiePropertyKey.path: "/",
HTTPCookiePropertyKey.name: "cookieName",
HTTPCookiePropertyKey.value: result.session,
HTTPCookiePropertyKey.secure : "Yes" as String]
let session: HTTPCookie! = HTTPCookie(properties: tokenCookieProperty)
guard let bridgeWebController = self.bridge?.webView else {
print("Unable to get Capacitor bridge wkwebview")
completion(nil)
return
}
HTTPCookieStorage.shared.removeCookies(since: Date(timeIntervalSince1970: 0))
HTTPCookieStorage.shared.setCookie(session)
bridgeWebController.configuration.websiteDataStore.httpCookieStore.setCookie(session)
bridgeWebController.reload()
}