Reuse access token from MSAL in web view

為{幸葍}努か 提交于 2021-02-17 03:25:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!