curl --request POST \
--url https://staging.housera.ro/api/v1/oauth/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data 'code=<string>' \
--data 'redirect_uri=<string>' \
--data 'code_verifier=<string>' \
--data 'client_id=<string>' \
--data 'client_secret=<string>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.housera.ro/api/v1/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=authorization_code&code=%3Cstring%3E&redirect_uri=%3Cstring%3E&code_verifier=%3Cstring%3E&client_id=%3Cstring%3E&client_secret=%3Cstring%3E",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
grant_type: 'authorization_code',
code: '<string>',
redirect_uri: '<string>',
code_verifier: '<string>',
client_id: '<string>',
client_secret: '<string>'
})
};
fetch('https://staging.housera.ro/api/v1/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://staging.housera.ro/api/v1/oauth/token"
payload = {
"grant_type": "authorization_code",
"code": "<string>",
"redirect_uri": "<string>",
"code_verifier": "<string>",
"client_id": "<string>",
"client_secret": "<string>"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text){
"access_token": "<string>",
"token_type": "Bearer",
"expires_in": 123,
"scope": "<string>",
"connection_id": 123
}{
"error": "invalid_client",
"error_description": "<string>"
}{
"error": "invalid_client",
"error_description": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>"
}Schimbă codul pe cheia contului
Pasul server la server din „Conectează cu Housera”: integratorul, autentificat cu secretul lui, schimbă codul de unică folosință primit pe adresa de întoarcere (și code_verifier-ul PKCE) pe cheia contului care a acceptat. Codul expiră în 60 de secunde și merge o singură dată; un cod folosit a doua oară revocă cheia pe care a dat-o. Ghidul complet e în pagina Conectează cu Housera.
curl --request POST \
--url https://staging.housera.ro/api/v1/oauth/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data 'code=<string>' \
--data 'redirect_uri=<string>' \
--data 'code_verifier=<string>' \
--data 'client_id=<string>' \
--data 'client_secret=<string>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.housera.ro/api/v1/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=authorization_code&code=%3Cstring%3E&redirect_uri=%3Cstring%3E&code_verifier=%3Cstring%3E&client_id=%3Cstring%3E&client_secret=%3Cstring%3E",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
grant_type: 'authorization_code',
code: '<string>',
redirect_uri: '<string>',
code_verifier: '<string>',
client_id: '<string>',
client_secret: '<string>'
})
};
fetch('https://staging.housera.ro/api/v1/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://staging.housera.ro/api/v1/oauth/token"
payload = {
"grant_type": "authorization_code",
"code": "<string>",
"redirect_uri": "<string>",
"code_verifier": "<string>",
"client_id": "<string>",
"client_secret": "<string>"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text){
"access_token": "<string>",
"token_type": "Bearer",
"expires_in": 123,
"scope": "<string>",
"connection_id": 123
}{
"error": "invalid_client",
"error_description": "<string>"
}{
"error": "invalid_client",
"error_description": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>"
}Parametri interogare
Limba răspunsului: mesajele (title, detail) și etichetele, ro sau en. Codurile sunt aceleași în orice limbă. Are întâietate față de Accept-Language și de limba contului.
ro, en Corp
Mereu authorization_code.
authorization_code Codul primit pe adresa de întoarcere, în ?code=.
Exact adresa de întoarcere din cererea de acord.
Verificatorul PKCE pe care l-ai generat înainte de cererea de acord (43–128 caractere).
43 - 128Identificatorul public al integratorului (hsrc_…). Se poate trimite și prin HTTP Basic.
Secretul integratorului (hsrs_…), doar de pe serverul tău. Se poate trimite și prin HTTP Basic.
Răspuns
Cheia contului, legată de integrator. Păstreaz-o pe server, lângă connection_id.
Cheia contului, de trimis ca Authorization: Bearer.
Mereu Bearer.
Bearer În câte secunde expiră cheia (365 de zile). Înainte de termen, contul trece din nou prin acord.
Drepturile acordate, separate prin spațiu.
Legătura cu acest cont. Vine în câmpul connection al fiecărui eveniment livrat pe webhook-ul integratorului.