Autenticação
A API do serviço de reconhecimento multibiométrico da TechTrue® utiliza o modelo de autenticação baseado em tokens. Para isso, deve-se utilizar as credenciais da aplicação para a geração do token que será enviado, no cabeçalho das requisições, para os endpoints do serviço de reconhecimento facial e reconhecimento de impressão digital.
Validar uma credencial
Para validação das credenciais, utilize o código abaixo:
curl -H "Content-Type: application/json" \-d '{"key": "{{key}}","secret": "{{secret}}"}' \"http://api.techtrue.com.br/api/v1/app-credentials/validate"const axios = require('axios');
let config = { method: 'post', maxBodyLength: Infinity, url: 'https://api.techtrue.com.br/api/v1/app-credentials/validate', headers: { 'Content-Type': 'application/json' }};
axios(config).then((response) => { console.log(JSON.stringify(response.data));}).catch((error) => { console.log(error);});Body payload
{}HTTP Request
POST /api/v1/app-credentials/validate
Parameters
| Name | Located in | Description | Required | Type |
|---|---|---|---|---|
| key | body | App key | yes | string |
| secret | body | Key’ secret | yes | string |
HTTP Response
| Code | Description |
|---|---|
| 200 | |
| 401 | Unauthorized |
Gerar um token
Para geração do token, utilize o código abaixo:
curl -H "Content-Type: application/json" \-d '{"key": "{{key}}","secret": "{{secret}}"}' \"http://api.techtrue.com.br/api/v1/app-credentials/token"const axios = require('axios');let data = JSON.stringify({ "key": "{{key}}", "secret": "{{secret}}"});
let config = { method: 'post', maxBodyLength: Infinity, url: 'https://api.techtrue.com.br/api/v1/app-credentials/token', headers: { 'Content-Type': 'application/json' }, data: data};
axios(config).then((response) => { console.log(JSON.stringify(response.data));}).catch((error) => { console.log(error);});Body payload
{ "token": "{{JWT token}}"}HTTP Request
POST /api/v1/app-credentials/token
Parameters
| Name | Located in | Description | Required | Type |
|---|---|---|---|---|
| key | body | App key | yes | string |
| secret | body | Key’ secret | yes | string |
HTTP Response
| Code | Description |
|---|---|
| 200 | |
| 401 | Unauthorized |
Exemplo de uso do token
curl 'http://api.techtrue.com.br/api/v1/services/face/count' \ -H 'Authorization: Bearer {{token}}'const axios = require('axios');
let config = { method: 'get', maxBodyLength: Infinity, url: 'https://api.techtrue.com.br/api/v1/services/face/count', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer {{token}}' }};
axios(config).then((response) => { console.log(JSON.stringify(response.data));}).catch((error) => { console.log(error);});Este token deverá ser enviado nas requisições utilizando o cabeçalho Authorization.