RefreshTokenAsync

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

Arguments

Copied to clipboard!
public async Task<JObject> RefreshTokenAsync(TimeSpan? expiresIn = null);

Optional:

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

Return

A JObject 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
Int64
Token expiration date, in Epoch-millis (UTC)
ttl
Int64
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 call, ensuring they are properly authenticated.

Usage

Copied to clipboard!
try {
  await kuzzle.Auth.LoginAsync(
    "local",
    JObject.Parse("{username: 'foo', password: 'bar'}"));
  JObject response = await kuzzle.Auth.RefreshTokenAsync();
  Console.WriteLine(response.ToString(Formatting.None));
  /*
  {
    "_id": "foo",
    "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfa...",
    "expiresAt": 1564569366389,
    "ttl": 3600000
  }
  */
} catch (KuzzleException e) {
  Console.WriteLine(e);
}