Authentification
L'intégralité de l'API est accessible en utilisant un token de connexion. Vous récupérerez votre token de connexion en utilisant le point d'entrée de login et utiliserez ce même token, jusqu'à son expiration, pour utiliser l'API de Timelight.
Nous utilisons un Json Web Token (JWT) comme token d'authentification, ce JWT contient toutes les informations nécessaires concernant son expiration. Vous pouvez également utiliser les lib standard de votre language pour gérer ce JWT.
Récupérer un JWT avec un login/password
curl -X POST -H "Content-Type: application/json" \
--data '{ "username" : "user", "password" : "secret" }' \
"${API_URL}/v1/user/login"
# response: { "jwt" : "..." }
import timelight_ai_python_api_client as tlc
conf = tlc.Configuration()
conf.host = "https://api.demo.timelight.tech"
user_api = tlc.UserApi(tlc.ApiClient(conf))
res = user_api.v1_user_login_post(tlc.LoginDto(username="demo", password="demo"))
jwt = res.jwt
const TimelightApi = require("timelight-ai-js-api-client")
const config = { basePath: "https://api.client-name.timelight.tech" }
const UserApi = new TimelightApi.UserApi(config);
UserApi
.v1UserLoginPost({ username: "demo", password: "demo" })
.then(res => console.log(res.jwt));
const config = { basePath: "https://api.client-name.timelight.tech" }
const UserApi = new TimelightApi.UserApi(config);
UserApi
.v1UserLoginPost({ username: "demo", password: "demo" })
.then(res => console.log(res.jwt));
import TimelightApi from "timelight-ai-js-api-client"
const config = { basePath: "https://api.client-name.timelight.tech" }
const UserApi = new TimelightApi.UserApi(config);
UserApi
.v1UserLoginPost({ username: "demo", password: "demo" })
.then(res => console.log(res.jwt));
$config = TimelightAi\Configuration::getDefaultConfiguration()
->setHost("https://api.demo.timelight.tech");
$userApi = new TimelightAi\Api\UserApi(new GuzzleHttp\Client(), $config);
$result = $userApi->v1UserLoginPost(
new TimelightAi\Model\LoginDto([
"username" => "demo",
"password" => "demo"
])
);
$jwt = $result["jwt"];
Appeler un point d'entrée en étant authentifié
Une fois le JWT récupéré, il vous faudra l'envoyer en en-tête des requêtes HTTP pour être authentifié :
curl -X GET -H "Authorization: Bearer ${JWT}" "${API_URL}/v1/source/list"
import timelight_ai_python_api_client as tlc
conf = tlc.Configuration()
conf.host = "https://api.demo.timelight.tech"
conf.api_key["Authorization"] = "Bearer " + jwt
source_api = tlc.SourceApi(tlc.ApiClient(conf))
res = source_api.v1_source_list_get()
const TimelightApi = require("timelight-ai-js-api-client")
const config = {
basePath: "https://api.demo.timelight.tech",
apiKey: "Bearer " + jwt,
}
const SourceApi = new TimelightApi.SourceApi(config);
const res = SourceApi.v1SourceListGet()
const config = {
basePath: "https://api.demo.timelight.tech",
apiKey: "Bearer " + jwt,
}
const SourceApi = new TimelightApi.SourceApi(config);
const res = SourceApi.v1SourceListGet()
import TimelightApi from "timelight-ai-js-api-client"
const config = {
basePath: "https://api.demo.timelight.tech",
apiKey: "Bearer " + jwt,
}
const SourceApi = new TimelightApi.SourceApi(config);
const res = SourceApi.v1SourceListGet()
$config = TimelightAi\Configuration::getDefaultConfiguration()
->setHost("https://api.demo.timelight.tech")
->setApiKey('Authorization', 'Bearer ' . $jwt);
$sourceApi = new TimelightAi\Api\SourceApi(new GuzzleHttp\Client(), $config);
$result = $sourceApi->v1SourceListGet();