AccessTokenProvider

@available(iOS 12.0, *)
public protocol AccessTokenProvider

A component providing “access tokens” for a user.

The Kaleyra Video SDK adopts a strong authentication mechanism based on JWT access tokens. Whenever the SDK needs an access token for a particular user, this component will be asked to provide an access token for a particular user You are required to provide a component conforming to this protocol as an argument of the Session object initialiser

  • The Kaleyra Video will call this method whenever an access token for the user identified by the userId parameter is required Once an access token is retrieved you should call the completion closure provided as second parameter reporting a result for the operation. This method may be invoked several times during the lifecycle of your app.

    Remark

    This method may be invoked from a background private queue, do not expect this method to be invoked from the main queue

    Declaration

    Swift

    func provideAccessToken(userId: String, completion: @escaping (Result<String, Error>) -> Void)

    Parameters

    userId

    A value identifying the user in the Kaleyra Video platform

    completion

    The completion closure you must invoke when either your component has retrieved an access token successfully or your component could not retrieve the access token because of an error