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
CommunicationTokenCredentialobject from the provided token.Throws
NSErrorif the provided token is not a valid user token.userInfocontainsmessagekey for reason.Declaration
Swift
public init(token: String) throwsParameters
tokenThe static token to use for authenticating all requests.
-
Creates a CommunicationTokenCredential that automatically refreshes the token.
Throws
NSErrorif the provided token is not a valid user token.userInfocontainsmessagekey for reason.Declaration
Swift
public init(withOptions options: CommunicationTokenRefreshOptions) throwsParameters
optionsOptions for how the token will be refreshed
-
Retrieve an access token from the credential.
Declaration
Swift
public func token(completionHandler: @escaping CommunicationTokenCompletionHandler)Parameters
completionHandlerClosure that accepts an optional
AccessTokenor optionalErroras parameters.AccessTokenreturns a token and an expiry date if applicable.Errorreturnsnilif the current token can be returned. -
Disposes the CommunicationTokenCredential and cancels any internal auto-refresh operation.
Declaration
Swift
public func cancel()
View on GitHub