ARTTokenRequest
Objective-C
@interface ARTTokenRequest : NSObject
Swift
class ARTTokenRequest : NSObject
Contains the properties of a request for a token to Ably. Tokens are generated using -[ARTAuthProtocol requestToken:].
-
The name of the key against which this request is made. The key name is public, whereas the key secret is private.
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull keyName;Swift
var keyName: String { get } -
The client ID to associate with the requested Ably Token. When provided, the Ably Token may only be used to perform operations on behalf of that client ID.
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *clientId;Swift
var clientId: String? { get set } -
A cryptographically secure random string of at least 16 characters, used to ensure the
ARTTokenRequestcannot be reused.Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull nonce;Swift
var nonce: String { get } -
The Message Authentication Code for this request.
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull mac;Swift
var mac: String { get } -
Capability of the requested Ably Token. If the Ably
ARTTokenRequestis successful, the capability of the returned Ably Token will be the intersection of this capability with the capability of the issuing key. The capabilities value is a JSON-encoded representation of the resource paths and associated operations. Read more about capabilities in the capabilities docs.Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *capability;Swift
var capability: String? { get set } -
Requested time to live for the Ably Token in milliseconds. If the Ably
ARTTokenRequestis successful, the TTL of the returned Ably Token is less than or equal to this value, depending on application settings and the attributes of the issuing key. The default is 60 minutes.Declaration
Objective-C
@property (nonatomic, nullable) NSNumber *ttl;Swift
var ttl: NSNumber? { get set } -
The timestamp of this request as
NSDateobject.Declaration
Objective-C
@property (nonatomic) NSDate *_Nonnull timestamp;Swift
var timestamp: Date { get set } -
A static factory method to create an
ARTTokenRequestobject from a deserializedTokenRequest-like object or a JSON stringifiedARTTokenRequestobject. This method is provided to minimize bugs as a result of differing types by platform for fields such astimestamporttl. For example, in Rubyttlin theTokenRequestobject is exposed in seconds as that is idiomatic for the language, yet when serialized to JSON usingto_jsonit is automatically converted to the Ably standard which is milliseconds. By using thefromJsonmethod when constructing aTokenRequestobject, Ably ensures that all fields are consistently serialized and deserialized across platforms.Declaration
Objective-C
+ (ARTTokenRequest *_Nullable)fromJson:(nonnull id<ARTJsonCompatible>)json error:(NSError *_Nullable *_Nullable)errorPtr;Swift
class func fromJson(_ json: any ARTJsonCompatible) throws -> ARTTokenRequestParameters
jsonA deserialized
TokenRequest-like object or a JSON stringifiedTokenRequestobject to create anARTTokenRequest.errorPtrA reference to the
NSErrorobject where an error information will be saved in case of failure.Return Value
An Ably token request object.