AuthenticationHandling

public protocol AuthenticationHandling : AnyObject

Defines an API capable of reacting to authentication results.

  • Called when an authentication process finished successfully and there is a new token / credential ready to use. If this delegate is present, all network request are hold until the completionHandler is called. If it is necessary to send a network request before calling the completionHandler (e.g. validating the new user), then mark the SAPURLSessionTask with the provided requestBypassIdentifier.

    Declaration

    Swift

    func authenticationObserver(_ observer: SAPURLSessionObserving, didAuthenticate session: SAPURLSession, requestBypassIdentifier: UUID, completionHandler: @escaping (Error?) -> Void)

    Parameters

    observer

    the SAPURLSessionObserving instance which handled the authentication process

    session

    the SAPURLSession instance involved in the authentication process

    requestBypassIdentifier

    the optional bypass identifier for network request before the completionHandler call

    completionHandler

    the completionHandler which must be called either with error or nil.

  • Called when an authentication process failed.

    Declaration

    Swift

    func authenticationObserver(_ observer: SAPURLSessionObserving, didFailToAuthenticate session: SAPURLSession, error: Error)

    Parameters

    observer

    the SAPURLSessionObserving instance which handled the authentication process

    session

    the SAPURLSession instance involved in the authentication process

    error

    the Error occured