Login.
curl --request POST \
--url https://lab.trustos.telefonicatech.com/id/v2/login \
--header 'Content-Type: application/json' \
--data '
{
"username": "did:user:<id>",
"password": "password"
}
'import requests
url = "https://lab.trustos.telefonicatech.com/id/v2/login"
payload = {
"username": "did:user:<id>",
"password": "password"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({username: 'did:user:<id>', password: 'password'})
};
fetch('https://lab.trustos.telefonicatech.com/id/v2/login', 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://lab.trustos.telefonicatech.com/id/v2/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'username' => 'did:user:<id>',
'password' => 'password'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://lab.trustos.telefonicatech.com/id/v2/login"
payload := strings.NewReader("{\n \"username\": \"did:user:<id>\",\n \"password\": \"password\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://lab.trustos.telefonicatech.com/id/v2/login")
.header("Content-Type", "application/json")
.body("{\n \"username\": \"did:user:<id>\",\n \"password\": \"password\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://lab.trustos.telefonicatech.com/id/v2/login")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"username\": \"did:user:<id>\",\n \"password\": \"password\"\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 200,
"message": "Login",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e"
}
}{
"statusCode": 400,
"type": "Validation Error",
"message": "Request parameters are wrong, check requirements",
"errors": [
{
"field": "",
"error": ""
}
]
}{
"statusCode": 401,
"type": "Authentication Error",
"message": "Token is not provided"
}{
"statusCode": 500,
"type": "Internal Server Error",
"message": "Oops! Something went wrong, please try again later"
}{
"statusCode": 503,
"type": "Service Unavailable Error",
"message": "Service temporarily unavailable, please try again later"
}Authentication
Login
Authenticates a user and issue a JSON Web Token (JWT) upon successful validation.
POST
/
login
Login.
curl --request POST \
--url https://lab.trustos.telefonicatech.com/id/v2/login \
--header 'Content-Type: application/json' \
--data '
{
"username": "did:user:<id>",
"password": "password"
}
'import requests
url = "https://lab.trustos.telefonicatech.com/id/v2/login"
payload = {
"username": "did:user:<id>",
"password": "password"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({username: 'did:user:<id>', password: 'password'})
};
fetch('https://lab.trustos.telefonicatech.com/id/v2/login', 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://lab.trustos.telefonicatech.com/id/v2/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'username' => 'did:user:<id>',
'password' => 'password'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://lab.trustos.telefonicatech.com/id/v2/login"
payload := strings.NewReader("{\n \"username\": \"did:user:<id>\",\n \"password\": \"password\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://lab.trustos.telefonicatech.com/id/v2/login")
.header("Content-Type", "application/json")
.body("{\n \"username\": \"did:user:<id>\",\n \"password\": \"password\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://lab.trustos.telefonicatech.com/id/v2/login")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"username\": \"did:user:<id>\",\n \"password\": \"password\"\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 200,
"message": "Login",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e"
}
}{
"statusCode": 400,
"type": "Validation Error",
"message": "Request parameters are wrong, check requirements",
"errors": [
{
"field": "",
"error": ""
}
]
}{
"statusCode": 401,
"type": "Authentication Error",
"message": "Token is not provided"
}{
"statusCode": 500,
"type": "Internal Server Error",
"message": "Oops! Something went wrong, please try again later"
}{
"statusCode": 503,
"type": "Service Unavailable Error",
"message": "Service temporarily unavailable, please try again later"
}The API has a token expiration mechanism in place, where the period of
validity of the issued JSON Web Token (JWT) is currently set to 30 minutes.
After this time, the JWT will no longer be valid and the user will need to
either call the “/refresh” method or log in again to obtain a new valid JWT.
This ensures the security of the user’s session and minimizes the risk of
unauthorised access to their account.
Body
application/json
Data needed for the login.
Was this page helpful?
⌘I