ARTAuthProtocol
Objective-C
@protocol ARTAuthProtocol
Swift
protocol ARTAuthProtocol
The protocol upon which the ARTAuth
is implemented.
-
A client ID, used for identifying this client when publishing messages or for presence purposes. The
clientId
can be any non-empty string, except it cannot contain a*
. This option is primarily intended to be used in situations where the library is instantiated with a key. Note that aclientId
may also be implicit in a token used to instantiate the library. An error is raised if aclientId
specified here conflicts with theclientId
implicit in the token. Find out more about identified clients.Declaration
Objective-C
@property (readonly, nullable) NSString *clientId;
Swift
var clientId: String? { get }
-
Calls the
requestToken
REST API endpoint to obtain an Ably Token according to the specifiedARTTokenParams
andARTAuthOptions
. BothARTTokenParams
andARTAuthOptions
are optional. When omitted ornil
, the default token parameters and authentication options for the client library are used, as specified in theARTClientOptions
when the client library was instantiated, or later updated with an explicit-[ARTAuthProtocol authorize:]
request. Values passed in are used instead of, rather than being merged with, the default values. To understand why an AblyARTTokenRequest
may be issued to clients in favor of a token, see Token Authentication explained.Declaration
Objective-C
- (void)requestToken:(nullable ARTTokenParams *)tokenParams withOptions:(nullable ARTAuthOptions *)authOptions callback:(nonnull ARTTokenDetailsCallback)callback;
Swift
func requestToken(_ tokenParams: ARTTokenParams?, with authOptions: ARTAuthOptions?, callback: @escaping ARTTokenDetailsCallback)
Parameters
tokenParams
An
ARTTokenParams
object.authOptions
An
ARTAuthOptions
object.callback
A callback for receiving an
ARTTokenDetails
object. -
See
-[ARTAuthProtocol requestToken:withOptions:callback:]
for details.Declaration
Objective-C
- (void)requestToken:(nonnull ARTTokenDetailsCallback)callback;
Swift
func requestToken(_ callback: @escaping ARTTokenDetailsCallback)
Parameters
callback
A callback for receiving an
ARTTokenDetails
object. -
Instructs the library to get a new token immediately. When using the realtime client, it upgrades the current realtime connection to use the new token, or if not connected, initiates a connection to Ably, once the new token has been obtained. Also stores any
ARTTokenParams
andARTAuthOptions
passed in as the new defaults, to be used for all subsequent implicit or explicit token requests. AnyARTTokenParams
andARTAuthOptions
objects passed in entirely replace, as opposed to being merged with, the current client library saved values.Declaration
Objective-C
- (void)authorize:(nullable ARTTokenParams *)tokenParams options:(nullable ARTAuthOptions *)authOptions callback:(nonnull ARTTokenDetailsCallback)callback;
Swift
func authorize(_ tokenParams: ARTTokenParams?, options authOptions: ARTAuthOptions?, callback: @escaping ARTTokenDetailsCallback)
Parameters
tokenParams
An
ARTTokenParams
object.authOptions
An
ARTAuthOptions
object.callback
A callback for receiving an
ARTTokenDetails
object. -
See
-[ARTAuthProtocol authorize:options:callback:]
for details.Declaration
Objective-C
- (void)authorize:(nonnull ARTTokenDetailsCallback)callback;
Swift
func authorize(_ callback: @escaping ARTTokenDetailsCallback)
Parameters
callback
A callback for receiving an
ARTTokenDetails
object. -
Creates and signs an Ably
ARTTokenRequest
based on the specified (or if none specified, the client library stored)ARTTokenParams
andARTAuthOptions
. Note this can only be used when the APIkey
value is available locally. Otherwise, the AblyARTTokenRequest
must be obtained from the key owner. Use this to generate an AblyARTTokenRequest
in order to implement an Ably Token request callback for use by other clients. BothARTTokenParams
andARTAuthOptions
are optional. When omitted ornil
, the default token parameters and authentication options for the client library are used, as specified in theARTClientOptions
when the client library was instantiated, or later updated with an explicit-[ARTAuthProtocol authorize:]
request. Values passed in are used instead of, rather than being merged with, the default values. To understand why an AblyARTTokenRequest
may be issued to clients in favor of a token, see Token Authentication explained.Declaration
Objective-C
- (void)createTokenRequest:(nullable ARTTokenParams *)tokenParams options:(nullable ARTAuthOptions *)options callback:(nonnull void (^)(ARTTokenRequest *_Nullable, NSError *_Nullable))callback;
Swift
func createTokenRequest(_ tokenParams: ARTTokenParams?, options: ARTAuthOptions?, callback: @escaping (ARTTokenRequest?, Error?) -> Void)
Parameters
tokenParams
An
ARTTokenParams
object.options
An
ARTAuthOptions
object.callback
A callback for receiving an
ARTTokenRequest
object. -
See
-[ARTAuthProtocol createTokenRequest:options:callback:]
for details.Declaration
Objective-C
- (void)createTokenRequest:(nonnull void (^)(ARTTokenRequest *_Nullable, NSError *_Nullable))callback;
Swift
func createTokenRequest(_ callback: @escaping (ARTTokenRequest?, Error?) -> Void)
Parameters
callback
A callback for receiving an
ARTTokenRequest
object.