How to use authentication?

As described in section Authentication, there are two methods to access protected data in the dataset: Bearer Token Login and OAuth2 authentication. Both authentication methods can be used within a browser or from the command line, with only slight differences. In this section we show how to use authentication within the Open Data Hub, provided that you owe an username and a password to access the closed data in the datasets.

To obtain the credentials, please address your enquiry to the contact email of the dataset you would like to access.

Bearer Token Login

Bearer token login is used to access the Datasets in the Tourism Domain; description of the procedure is available at Data Access and Manipulation.

OAuth2 authentication

OAuth2 authentication can be used in all the Datasets in the Mobility Domain that are marked with the This dataset requires authorisation badge, so pick one dataset and go to its swagger interface, whose URL is provided together with the information of the dataset.


As of Jul 16, 2019, authentication is not yet publicly available, so the following guidelines can not yet be put in practice.

If you use a browser

Make sure you have obtained a valid username and password, then open the /rest/refresh-token method and write you username and password in the two user and pw fields, respectively, as shown in Figure 23.


Figure 23 Request a new OAuth2 token.

If your credentials are valid, you will receive a new token, otherwise the response will be a 401 Unauthorized error message.

The token you received can be used in any of the API’s methods that require authorisation. A sample call is shown in figure Figure 24. Note the syntax of the Autorization parameter: You must use prefix the authentication token with the Bearer string, followed by an empty space, then by the token.


Figure 24 A successful call to a method requiring authentication.

In case you do not respect the Authorization+space+token sequence, use additional separators in the sequence (like Figure 25 shows), or use an invalid token, you will receive an 401 - Unauthorized HTTP response.


Figure 25 A failed call to a method requiring authentication.

If you use the Command Line Interface.

Open a shell on your workstation and use a tool like curl or wget, with the appropriate options:


Specify the request method (GET)

--header, -H

Add extra header information to be included in the request.

Note that the --header option is used twice: The first to receive the answer in text/html format, the second to provide the credentials required to access protected content.

API calls can be done using a tool like curl or wget, with the same -X and --header option used twice: The first to require the format of the response, the second to provide the credentials, like for example:

curl -X GET "" --header "Accept: */*" --header 'Authorization: Bearer <token>'

Make sure to replace the <token> with the actual token you received.