Optional
authA set of key-value pair headers to be added to any request made to the authUrl
. Useful when an application requires these to be added to validate the request or implement the response. If the authHeaders
object contains an authorization
key, then withCredentials
is set on the XHR request.
Optional
authThe HTTP verb to use for any request made to the authUrl
, either GET
or POST
. The default value is GET
.
HTTPMethods.GET
Optional
authA set of key-value pair params to be added to any request made to the authUrl
. When the authMethod
is GET
, query params are added to the URL, whereas when authMethod
is POST
, the params are sent as URL encoded form data. Useful when an application requires these to be added to validate the request or implement the response.
Optional
authA URL that the library may use to obtain a token string (in plain text format), or a signed TokenRequest or TokenDetails (in JSON format) from.
Optional
clientA 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 will be raised if a clientId
specified here conflicts with the clientId
implicit in the token. Find out more about client identities.
Optional
key
The full API key string, as obtained from the Ably dashboard. Use this option if you wish to use Basic authentication, or wish to be able to issue Ably Tokens without needing to defer to a separate entity to sign Ably TokenRequest
s. Read more about Basic authentication.
Optional
queryIf true
, the library queries the Ably servers for the current time when issuing TokenRequest
s instead of relying on a locally-available time of day. Knowing the time accurately is needed to create valid signed Ably TokenRequest
s, so this option is useful for library instances on auth servers where for some reason the server clock cannot be kept synchronized through normal means, such as an NTP daemon. The server is queried for the current time once per client library instance (which stores the offset from the local clock), so if using this option you should avoid instancing a new version of the library for each request. The default is false
.
false
Optional
token
An authenticated token. This can either be a TokenDetails object or token string (obtained from the token
property of a TokenDetails component of an Ably TokenRequest response, or a JSON Web Token satisfying the Ably requirements for JWTs). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that enables the client library to renew the token automatically when the previous one expires, such as authUrl
or authCallback
. Read more about Token authentication.
Optional
tokenAn authenticated TokenDetails object (most commonly obtained from an Ably Token Request response). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that enables the client library to renew the token automatically when the previous one expires, such as authUrl
or authCallback
. Use this option if you wish to use Token authentication. Read more about Token authentication.
Optional
useWhen true
, forces token authentication to be used by the library. If a clientId
is not specified in the ClientOptions or TokenParams, then the Ably Token issued is anonymous.
Optional
authCalled when a new token is required. The role of the callback is to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed TokenRequest; a TokenDetails (in JSON format); an Ably JWT. See the authentication documentation for details of the Ably TokenRequest format and associated API calls.
The parameters that should be used to generate the token.
A function which, upon success, the authCallback
should call with one of: an Ably Token string (in plain text format); a signed TokenRequest
; a TokenDetails
(in JSON format); an Ably JWT. Upon failure, the authCallback
should call this function with information about the error.
A function which, upon success, the authCallback
should call with one of: an Ably Token string (in plain text format); a signed TokenRequest
; a TokenDetails
(in JSON format); an Ably JWT. Upon failure, the authCallback
should call this function with information about the error.
Should be null
if the auth request completed successfully, or containing details of the error if not.
A valid TokenRequest
, TokenDetails
or Ably JWT to be used for authentication.
Generated using TypeDoc
Passes authentication-specific properties in authentication requests to Ably. Properties set using
AuthOptions
are used instead of the default values set when the client library is instantiated, as opposed to being merged with them.