SDK
SDK C# v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

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 #

public async Task<JObject> RefreshTokenAsync(TimeSpan? expiresIn = null);

Optional:

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

Return #

A JObject with the following properties:

PropertyTypeDescription
_id
string
User's kuid
jwt
string
Encrypted JSON Web 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 JWT is stored by the SDK and used for all the subsequent API call, ensuring they are properly authenticated.

Usage #

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);
}