SDK
SDK Jvm v1.x
2

RefreshToken #

Refreshes an authentication token.

  • a valid, non-expired authentication must be provided
  • the provided authentication token is revoked
  • a new authentication token is generated and returned

:::: tabs ::: tab Java

Arguments #

Copied to clipboard!
CompletableFuture<Map<String, Object>> refreshToken(
  String expiresIn) throws NotConnectedException, InternalException

CompletableFuture<Map<String, Object>> refreshToken()
  throws NotConnectedException, InternalException

Optional:

Argument Type Description
expiresIn
String
Set the token expiration duration (default: depends on Kuzzle configuration file)

Return #

A Map with the following properties:

Property Type Description
_id
String
User's kuid
jwt
String
Encrypted authentication token, that must then be sent in the requests headers or in the query
expiresAt
int
Token expiration date, in Epoch-millis (UTC)
ttl
int
Token time to live, in milliseconds

Once auth:refreshToken has been called, the returned authentication token is stored by the SDK and used for all the subsequent API calls.

Usage #

Copied to clipboard!
Map<String, Object> credentials = new HashMap<>();
credentials.put("username", "foo");
credentials.put("password", "bar");
kuzzle.getAuthController().login("local", credentials).get();
Map<String, Object> result =
  kuzzle.getAuthController().refreshToken("1h").get();

::: ::: tab Kotlin

Arguments #

Copied to clipboard!
fun refreshToken(
      expiresIn: String? = null): CompletableFuture<Map<String, Any?>>

Optional:

Argument Type Description
expiresIn
String
Set the token expiration duration (default: depends on Kuzzle configuration file)

Return #

A Map with the following properties:

Property Type Description
_id
String
User's kuid
jwt
String
Encrypted authentication token, that must then be sent in the requests headers or in the query
expiresAt
Int
Token expiration date, in Epoch-millis (UTC)
ttl
Int
Token time to live, in milliseconds

Once auth:refreshToken has been called, the returned authentication token is stored by the SDK and used for all the subsequent API calls.

Usage #

Copied to clipboard!
kuzzle.authController.login("local", HashMap<String, Any?>().apply {
  put("username", "foo")
  put("password", "bar")
}).get()
val result: Map<String, Any?> =
  kuzzle.authController.refreshToken("1h").get();

::: ::::