Python
# At your gateway: check the token offline, with the space's public keys kept in memory
gateway = niadra.contact_gateway("wa_gateway", space=SPACE_ID, key=GATEWAY_KEY)
claims = gateway.verify(token, channel="whatsapp", destination="phone:+5511987654321") # raises ContactTokenError// At your gateway: check the token offline, with the space's public keys kept in memory
const gateway = niadra.contactGateway("wa_gateway", { space: SPACE_ID, key: GATEWAY_KEY });
const claims = await gateway.verify(token, { channel: "whatsapp", destination: "phone:+5511987654321" }); // rejects with NiadraContactTokenErrorcurl --request GET \
--url https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.jsonconst options = {method: 'GET'};
fetch('https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"keys": [
{
"kid": "<string>",
"space": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"x": "<string>",
"crv": "Ed25519",
"kty": "OKP",
"not_after": "2023-11-07T05:31:56Z",
"status": "active"
}
]
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Coordination
Contact token public keys
The Ed25519 keys of one space, as JWKs, with which your gateway checks a contact token without talking to Niadra. Public.
GET
/
.well-known
/
niadra-contact-keys.json
Python
# At your gateway: check the token offline, with the space's public keys kept in memory
gateway = niadra.contact_gateway("wa_gateway", space=SPACE_ID, key=GATEWAY_KEY)
claims = gateway.verify(token, channel="whatsapp", destination="phone:+5511987654321") # raises ContactTokenError// At your gateway: check the token offline, with the space's public keys kept in memory
const gateway = niadra.contactGateway("wa_gateway", { space: SPACE_ID, key: GATEWAY_KEY });
const claims = await gateway.verify(token, { channel: "whatsapp", destination: "phone:+5511987654321" }); // rejects with NiadraContactTokenErrorcurl --request GET \
--url https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.jsonconst options = {method: 'GET'};
fetch('https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/.well-known/niadra-contact-keys.json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"keys": [
{
"kid": "<string>",
"space": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"x": "<string>",
"crv": "Ed25519",
"kty": "OKP",
"not_after": "2023-11-07T05:31:56Z",
"status": "active"
}
]
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}
