Creates Ably TokenRequest objects and obtains Ably Tokens from Ably to subsequently issue to less trusted clients.

Hierarchy

Constructors

Properties

clientId: string

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 a clientId may also be implicit in a token used to instantiate the library. An error is raised if a clientId specified here conflicts with the clientId implicit in the token. Find out more about identified clients.

Methods

  • 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 TokenParams and AuthOptions passed in as the new defaults, to be used for all subsequent implicit or explicit token requests. Any TokenParams and AuthOptions objects passed in entirely replace, as opposed to being merged with, the current client library saved values.

    Returns

    A promise which, upon success, will be fulfilled with a TokenDetails object. Upon failure, the promise will be rejected with an ErrorInfo object which explains the error.

    Parameters

    Returns Promise<TokenDetails>

  • Creates and signs an Ably TokenRequest based on the specified (or if none specified, the client library stored) TokenParams and AuthOptions. Note this can only be used when the API key value is available locally. Otherwise, the Ably TokenRequest must be obtained from the key owner. Use this to generate an Ably TokenRequest in order to implement an Ably Token request callback for use by other clients. Both TokenParams and AuthOptions are optional. When omitted or null, the default token parameters and authentication options for the client library are used, as specified in the ClientOptions when the client library was instantiated, or later updated with an explicit authorize request. Values passed in are used instead of, rather than being merged with, the default values. To understand why an Ably TokenRequest may be issued to clients in favor of a token, see Token Authentication explained.

    Returns

    A promise which, upon success, will be fulfilled with a TokenRequest object. Upon failure, the promise will be rejected with an ErrorInfo object which explains the error.

    Parameters

    Returns Promise<TokenRequest>

Generated using TypeDoc