BrowserBasedAuthenticationHandlerDelegate
public protocol BrowserBasedAuthenticationHandlerDelegate : FailableAuthenticationHandlerDelegate
Authentication handlers that rely on calling an a web-based oAuth2 authentication flow to gather and validate authentication credentials will support this delegate to support display of the authentication web page, detecting the oAuth2 redirectURI and handling errors.
-
Implementation Required
Called when/if the UI should display the authentication URL for web-based oAuth2 authentication.
Example:
Assuming you’re using a WKWebView to load the authentication page, in your WKNavigationDelegate object:
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { if let url = navigationAction.request.url { if shouldFollowRedirect(to: url) { decisionHandler(.allow) return } decisionHandler(.cancel) } }Declaration
Swift
func authenticationHandler(_ authenticationHandler: AuthenticationHandler, loadWebAuthenticationUrl url: URL, shouldFollowRedirect: @escaping (_ to: URL) -> (Bool))Parameters
authenticationHandlerthe authenticationHandler associated with this delegate
urlThe URL to display
shouldFollowRedirectA closure that parses the provided URL and determines if the URL is the expected post-authentication redirect URI.
toThe URL to parse in
shouldFollowRedirectReturn Value
True if the normal redirect web page loading should be allowed to continue. False if the provided URL was in fact the expected oAuth2 redirect URI, and the web view should not continue loading.
-
authenticationHandler(_:willStoreQueryParameters:)Default implementationImplementation optional
Allows for modifying, type conversion, or adding to the oAuth2 authentication response’s query string provided metadata during the authentication process.
After validating the oAuth2 redirect, the authentication process parses the redirect’s query string. This delegate method is called after the query string has been parsed, but prior to storing that data in the AuthenticationHandler’s
authenticationResponsePayloadproperty. The return value from this method is what is stored.Default Implementation
If no implementation is provided, this function returns same dictionary as was provided in the
queryStringInfoparameter.Declaration
Swift
func authenticationHandler(_ authenticationHandler: AuthenticationHandler, willStoreQueryParameters queryStringInfo: [String: String]) -> [String: Any]Parameters
authenticationHandlerthe AuthenticationHandler associated with this delegate
queryStringInfoDictionary of the parsed query string.
Return Value
Dictionary of authentication information
View on GitHub
BrowserBasedAuthenticationHandlerDelegate Protocol Reference