Skip to content

Commit

Permalink
[api] new auth:refreshToken API route documentation (#262)
Browse files Browse the repository at this point in the history
# Description

Document the new `auth:refreshToken` API route

# How to review

Go to the `api/1/controller-auth/refresh-token/` URL in the netlify preview
  • Loading branch information
scottinet authored Mar 25, 2019
1 parent fcd3c3a commit 2476faa
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/api/1/controller-auth/refresh-token/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
layout: full.html.hbs
title: refreshToken
---

# refreshToken

{{{since "1.7.0"}}}

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

---

## Query Syntax

### HTTP

```http
URL: http://kuzzle:7512/_refreshToken[?expiresIn=<expiresIn>]
Method: POST
```

### Other protocols

```js
{
"controller": "auth",
"action": "refreshToken",
"expiresIn": "<expiresIn>"
}
```

---

## Arguments

### Optional:

* `expiresIn`: set the expiration duration (default: depends on [Kuzzle configuration file]({{ site_base_path }}guide/1/essentials/configuration/))
* if a raw number is provided (not enclosed between quotes), then the expiration delay is in milliseconds. Example: `86400000`
* if this value is a string, then its content is parsed by the [ms](https://www.npmjs.com/package/ms) library. Examples: `"6d"`, `"10h"`

---

## Response

The result contains the following properties:

* `_id`: user's [kuid]({{ site_base_path }}guide/1/kuzzle-depth/authentication#the-kuzzle-user-identifier)
* `jwt`: encrypted JSON Web Token, that must then be sent in the [requests headers]({{ site_base_path }}api/1/essentials/query-syntax/#http-default) or in the [query]({{ site_base_path }}api/1/essentials/query-syntax/#other-protocols-default)
* `expiresAt`: new token expiration date, in Epoch-millis (UTC)
* `ttl`: new token time to live, in milliseconds

```javascript
{
"status": 200,
"error": null,
"controller": "auth",
"action": "refreshToken",
"requestId": "<unique request identifier>",
"volatile": {},
"result": {
"_id": "<kuid>",
"jwt": "<JWT encrypted token>",
"expiresAt": 1321085955000,
"ttl": 360000
}
}
```

0 comments on commit 2476faa

Please sign in to comment.