Skip to main content
Skip table of contents

Prerequisites Romania

Prerequisites

In order to create an OAuth profile, the customer needs a Romanian tax number issued by the Romanian tax authority ANAF (Agenția Națională de Administrare Fiscală).

To obtain an OAuth profile, the taxpayer must acquire a qualified certificate for electronic signature from one of the Trust Service Providers in Romania.

Link https://eidas.ec.europa.eu/efda/tl-browser/#/screen/tl/RO

image-20240729-121004.png

How to generate the authorization token

To integrate ANAF services exposed on the Internet with third-party applications (web, desktop, or mobile), ANAF has implemented a solution to authorize access to API-type services, using standard mechanisms based on the use of the OAUTH protocol. This solution uses standard mechanisms based on the OAUTH protocol and is intended for application developers with knowledge of IT and of the Oauth 2.0 protocol. This is because application development is required to use this solution.

The following steps are required to obtain the credentials:

Retrieve the client ID and the client secret

Go to the ANAF web page, then select the link under Autentificare utilizator (user authentication):

image-20240729-122118.png

Enter the username and the password and proceed to log in:

image-20240801-084645.png

Once logged in, go to Editare profil Oauth (Edit Oauth profile):

image-20240801-084717.png

After reaching the application registration page, multiple services will be available under the Meniu (Menu):

image-20240801-084757.png

Select the Gestionare aplicații (Application management) option:

image-20240801-084833.png

Next, fill in the information and select the E-Factura for Serviciu (Service).
Additionally, select E-Transport if you intend to use the RO e-Transport system. 

If the customer uses the Postman application, it’s possible to use https://oauth.pstmn.io/v1/callback as a callback URL. This is where the response from ANAF is sent received when the request is processed, but it will simply appear in your browser along with authorization code (explained in more detail in the next chapter).

In case the customer is not using Postman, it’s possible to use any URL, it just needs to exist as your browser will call it during successful authorization later.

image-20240801-084916.png

After pressing the Generare Client ID button, the customer can retrieve the client ID and the client secret.

image-20240801-084946.png

Retrieve access and refresh token 

In this step, after registering an application (obtaining the client ID and secret), we can proceed to obtain the access and refresh tokens. This process consists of two main steps. It is recommended to prepare step 2 in Postman before executing both steps, as the ‘authorization code’ is short-lived.

GET authorization code:

  1. Customers must open the following link in the browser, replacing the clientId XXX and callback URL YYY with the values obtained when registering the application at ANAF:

https://logincert.anaf.ro/anaf-oauth2/v1/authorize?client_id=XXX&response_type=code&redirect_uri=YYY&token_content_type=jwt.

Note that the customer must do this in the same browser where their qualified certificate is installed. The process might involve popups, therefore we recommend disabling popup blockers for this part.

  1. In the browser, the customer will be asked to authenticate against the Certificate Authority from which their qualified certificate was issued.

  2. Upon successful authentication, there will be an authorization code in the response URL that should be copied from the browser.

POST authorization code:

The client must open Postman and configure the following call as in the image:

image-20240801-085406.png

This is the URL used in the image for easier reference: https://logincert.anaf.ro/anaf-oauth2/v1/token

  1. The following must be filled in, like in the image:

    1. Grant type: The fixed value “Authorization Code”.

    2. Redirect URI: Configured by the customer when enrolling the application.

    3. Client ID: obtained by the customer when registering the application

    4. Client secret: obtained by the customer when registering the application

    5. Code: The authorization code obtained in step 1.3 (above).

    6. Token Content Type: The fixed value “jwt”.

  2. Select “Send” in Postman

  3. The response will contain an access token and a refresh token.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.