问题
In my iOS app I'm currently authenticating through the MSAL iOS SDK and it's working fine. Somewhere in the app I'm also required to show a website (opened via UIWebView) that also requires the same Azure AD authentication. Since I'm already authenticated through the SDK and have an access token, is there any way to bypass authentication process in the web view?
回答1:
You can use one of the following for cookie sharing:
1. ASWebAuthenticationSession in MSAL + open URL in Safari browser
MSAL
var webViewParamaters : MSALWebviewParameters webViewParamaters.webviewType = .authenticationSession
WEB
UIApplication.shared.open(URL(string: "your URL")!)
2. SFSafariViewController in MSAL + open URL in SFSafariViewController
MSAL
var webViewParamaters : MSALWebviewParameters webViewParamaters.webviewType = .safariViewController
WEB
SFSafariViewController(url: URL(string: "your URL")!)
NOTE: WKWebView in MSAL and WKWebView to open URL will not work.
来源:https://stackoverflow.com/questions/57800669/reuse-access-token-from-msal-in-web-view