CommunicationTokenCredential
@objcMembers
public class CommunicationTokenCredential : NSObject, Cancellable
The Azure Communication Services User token credential. This class is used to cache/refresh the access token required by Azure Communication Services.
-
Creates a static
CommunicationTokenCredential
object from the provided token.Throws
NSError
if the provided token is not a valid user token.userInfo
containsmessage
key for reason.Declaration
Swift
public init(token: String) throws
Parameters
token
The static token to use for authenticating all requests.
-
Creates a CommunicationTokenCredential that automatically refreshes the token.
Throws
NSError
if the provided token is not a valid user token.userInfo
containsmessage
key for reason.Declaration
Swift
public init(withOptions options: CommunicationTokenRefreshOptions) throws
Parameters
options
Options for how the token will be refreshed
-
Retrieve an access token from the credential.
Declaration
Swift
public func token(completionHandler: @escaping CommunicationTokenCompletionHandler)
Parameters
completionHandler
Closure that accepts an optional
AccessToken
or optionalError
as parameters.AccessToken
returns a token and an expiry date if applicable.Error
returnsnil
if the current token can be returned. -
Disposes the CommunicationTokenCredential and cancels any internal auto-refresh operation.
Declaration
Swift
public func cancel()