Package io.ably.lib.rest
Class Auth.AuthOptions
java.lang.Object
io.ably.lib.rest.Auth.AuthOptions
- Direct Known Subclasses:
ClientOptions
- Enclosing class:
- Auth
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.
-
Field Summary
Modifier and TypeFieldDescriptionCalled when a new token is required.Param[]
A set of key-value pair headers to be added to any request made to the authUrl.The HTTP verb to use for any request made to the authUrl, either GET or POST.Param[]
A set of key-value pair params to be added to any request made to the authUrl.A URL that the library may use to obtain a token string (in plain text format), or a signedAuth.TokenRequest
orAuth.TokenDetails
(in JSON format) from.The full API key string, as obtained from the Ably dashboard.boolean
If true, the library queries the Ably servers for the current time when issuingAuth.TokenRequest
instead of relying on a locally-available time of day.An authenticated token.An authenticatedAuth.TokenDetails
object (most commonly obtained from an Ably Token Request response).boolean
When true, forces token authentication to be used by the library. -
Constructor Summary
ConstructorDescriptionDefault constructorAuthOptions
(String key) Convenience constructor, to create an AuthOptions based on the key string obtained from the application dashboard. -
Method Summary
-
Field Details
-
authCallback
Called 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 signedAuth.TokenRequest
; aAuth.TokenDetails
(in JSON format); an Ably JWT. See the authentication documentation for details of the AblyAuth.TokenRequest
format and associated API calls.This callback is invoked on a background thread.
Spec: RSA4a, RSA4, TO3j5, AO2b
-
authUrl
A URL that the library may use to obtain a token string (in plain text format), or a signedAuth.TokenRequest
orAuth.TokenDetails
(in JSON format) from.Spec: RSA4a, RSA4, RSA8c, TO3j6, AO2c
-
authMethod
The HTTP verb to use for any request made to the authUrl, either GET or POST. The default value is GET.Spec: RSA8c, TO3j7, AO2d
-
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 AblyAuth.TokenRequest
. Read more about Basic authentication.Spec: RSA11, RSA14, TO3j1, AO2a
-
token
An authenticated token. This can either be aAuth.TokenDetails
object, aAuth.TokenRequest
object, or token string (obtained from the token property of aAuth.TokenDetails
component of an AblyAuth.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.Spec: RSA4a, RSA4, TO3j2
-
tokenDetails
An authenticatedAuth.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.Spec: RSA4a, RSA4, TO3j2
-
authHeaders
A 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.Spec: RSA8c3, TO3j8, AO2e
-
authParams
A 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.Spec: RSA8c3, RSA8c1, TO3j9, AO2f
-
queryTime
public boolean queryTimeIf true, the library queries the Ably servers for the current time when issuingAuth.TokenRequest
instead of relying on a locally-available time of day. Knowing the time accurately is needed to create valid signed AblyAuth.TokenRequest
, 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.Spec: RSA9d, TO3j10, AO2a
-
useTokenAuth
public boolean useTokenAuthWhen true, forces token authentication to be used by the library. If a clientId is not specified in theClientOptions
orAuth.TokenParams
, then the Ably Token issued is anonymous.Spec: RSA4, RSA14, TO3j4
-
-
Constructor Details
-
AuthOptions
public AuthOptions()Default constructor -
AuthOptions
Convenience constructor, to create an AuthOptions based on the key string obtained from the application dashboard.- Parameters:
-
key
- the full key string as obtained from the dashboard - Throws:
AblyException
-