Generate unique credentials for your project to authenticate future API calls.
curl --request POST \
--url http://{{you-endpoint}}:{{your-port}}/root/create \
--header 'Authorization: {{root-key}}' \
--header 'content-type: application/json' \
--data '{
"name":"app_1",
"description":"description",
"token_expire": 3600,
"token_notbefore":0,
"refresh_expire": 7200,
"refresh_notbefore" : 3000,
"algo":"ES256",
"key_type": "ECDSA",
"rotation_period": 31536000
}'
const request = require('request');
const options = {
method: 'POST',
url: 'http://{{you-endpoint}}:{{your-port}}/root/create',
headers: {Authorization: '{{root-key}}', 'content-type': 'application/json'},
body: {
name: 'app_1',
description: 'description',
token_expire: 3600,
token_notbefore: 0,
refresh_expire: 7200,
refresh_notbefore: 3000,
algo: 'ES256',
key_type: 'ECDSA',
rotation_period: 31536000
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
import requests
url = "http://{{you-endpoint}}:{{your-port}}/root/create"
payload = {
"name": "app_1",
"description": "description",
"token_expire": 3600,
"token_notbefore": 0,
"refresh_expire": 7200,
"refresh_notbefore": 3000,
"algo": "ES256",
"key_type": "ECDSA",
"rotation_period": 31536000
}
headers = {
"Authorization": "{{root-key}}",
"content-type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'http://{{you-endpoint}}:{{your-port}}/root/create', [
'body' => '{
"name":"app_1",
"description":"description",
"token_expire": 3600,
"token_notbefore":0,
"refresh_expire": 7200,
"refresh_notbefore" : 3000,
"algo":"ES256",
"key_type": "ECDSA",
"rotation_period": 31536000
}',
'headers' => [
'Authorization' => '{{root-key}}',
'content-type' => 'application/json',
],
]);
echo $response->getBody();
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://{{you-endpoint}}:{{your-port}}/root/create"
payload := strings.NewReader("{\n \"name\":\"app_1\",\n \"description\":\"description\",\n \"token_expire\": 3600,\n \"token_notbefore\":0,\n \"refresh_expire\": 7200,\n \"refresh_notbefore\" : 3000,\n \"algo\":\"ES256\",\n \"key_type\": \"ECDSA\",\n \"rotation_period\": 31536000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "{{root-key}}")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "http://{{you-endpoint}}:{{your-port}}/root/create")
.setHeader("Authorization", "{{root-key}}")
.setHeader("content-type", "application/json")
.setBody("{\n \"name\":\"app_1\",\n \"description\":\"description\",\n \"token_expire\": 3600,\n \"token_notbefore\":0,\n \"refresh_expire\": 7200,\n \"refresh_notbefore\" : 3000,\n \"algo\":\"ES256\",\n \"key_type\": \"ECDSA\",\n \"rotation_period\": 31536000\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();