---
title: "Autentificarea în API | Ghidul dezvoltatorului | R&D Copilot"
lang: ro
canonical: https://rdcopilot.com/ro/docs/authentication/
content_version: a99f45e8c2c8482cffac15a805b035caa0f3463215a0663a0429f0d3ee10378b
contact: https://rdcopilot.com/ro/contact/
---

# Autentificarea în API

Cei doi pași care autentifică un apel, scope-ul fiecărui produs, cât timp păstrezi un token și ce înseamnă 401 și 403.

Codul se autentifică drept client prin OAuth 2.0 client credentials și trimite tokenul primit ca token bearer.

## Pasul 1: cere un token

Trimite identificatorul de client și secretul integrării tale la adresa pentru token primită odată cu contul și setează `scope` la scope-ul produsului: `<product>.access`.

Cererea de token

```bash
curl -X POST "$RDC_TOKEN_URL" \
  -d "grant_type=client_credentials" \
  -d "client_id=$RDC_CLIENT_ID" \
  -d "client_secret=$RDC_CLIENT_SECRET" \
  -d "scope=inventory.access"
```

Răspunsul conține tokenul și cât timp este valabil.

Răspuns 200

```json
{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.e30.c2lnbmF0dXJl",
  "token_type": "Bearer",
  "expires_in": 300
}
```

| Câmp | Descriere |
| --- | --- |
| `access_token` | Tokenul. |
| `token_type` | Întotdeauna `Bearer`. |
| `expires_in` | Secundele rămase până la expirarea tokenului. Valoarea din răspunsul tău este cea care contează. |

## Pasul 2: trimite tokenul

Pune tokenul în antetul `Authorization` al fiecărei cereri: `Authorization: Bearer $RDC_TOKEN`. Fiecare exemplu din acest ghid o face.

## Scope-urile

Un scope, `<product>.access`, dă acces la un singur produs, de exemplu `inventory.access`. Un client cere scope-urile produselor pe care le apelează și le poate folosi doar pe acestea.

## Un client, o societate

Un client este emis pentru o singură societate, iar tokenul lui ajunge doar la datele acelei societăți. O a doua societate are nevoie de un al doilea client: cere-l echipei noastre prin [formularul de contact](https://rdcopilot.com/ro/contact/?topic=api-access).

## Un token expiră

Reutilizează un token până trec `expires_in` secunde, apoi cere unul nou. Nu cere un token la fiecare cerere: adaugă încă o cerere la fiecare apel.

| Cod de stare | Cod | Cauză | Ce faci |
| --- | --- | --- | --- |
| `401` | `unauthorized` | Tokenul lipsește, a expirat sau nu este al nostru. | Cere un token nou, apoi trimite din nou cererea. |
| `403` | `forbidden` | Tokenul nu dă acces la această societate sau operație. | Nu o repeta. Verifică scope-ul și societatea clientului. |

## Păstrarea secretului

-   Folosește un client pentru fiecare integrare și pentru fiecare mediu, ca un secret să poată fi rotit fără să le atingi pe celelalte.
-   Păstrează secretul pe un server pe care îl controlezi. Nu îl pune niciodată într-o pagină web sau într-o aplicație mobilă.
-   Rotirea trece prin echipa noastră: scrie prin [formularul de contact](https://rdcopilot.com/ro/contact/?topic=api-access).

Parola unei persoane nu servește niciodată la accesul în API. Oamenii se autentifică în aplicații; codul se autentifică drept client.

## În documentația produselor

-   [ERP: Accesul produsului](https://erp.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [Inventory: Accesul produsului](https://inventory.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [WMS: Accesul produsului](https://warehouse.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [POS: Accesul produsului](https://pos.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [Self-Checkout: Accesul produsului](https://checkout.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [Accounting: Accesul produsului](https://accounting.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [Treasury: Accesul produsului](https://banking.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [HR: Accesul produsului](https://hr.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [Payroll: Accesul produsului](https://payroll.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [eLearning: Accesul produsului](https://elearning.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [CRM: Accesul produsului](https://crm.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [AI Assistant: Accesul produsului](https://ai.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [Private AI Workspace: Accesul produsului](https://private-ai.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [DMS: Accesul produsului](https://documents.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [BI: Accesul produsului](https://reports.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [IoT: Accesul produsului](https://iot.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [e-Factura Gateway: Accesul produsului](https://efactura.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [e-TVA Check: Accesul produsului](https://etva.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [e-Transport Gateway: Accesul produsului](https://etransport.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [Tax Filing: Accesul produsului](https://declarations.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [REGES Gateway: Accesul produsului](https://reges.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)
-   [Integrations: Accesul produsului](https://integrations.rdcopilot.com/ro/docs/get-started/authentication/#request-a-token)

## Pagini înrudite

-   [Prima cerere](https://rdcopilot.com/ro/docs/first-request/): tokenul folosit în cereri.
-   [Autentificarea cu R&D Copilot](https://rdcopilot.com/ro/docs/sign-in/): cum deschid oamenii aplicațiile.

[Pagina anterioară · **Autentificarea cu R&D Copilot**](https://rdcopilot.com/ro/docs/sign-in/) [Pagina următoare · **Prima cerere**](https://rdcopilot.com/ro/docs/first-request/)

---

R&D Copilot · Realizat în UE · Contact: https://rdcopilot.com/ro/contact/
