Table of Contents |
---|
Introduction
...
Create new OAuth2 client application as instructed in Management UI Applications or alternatively use the Management API. Allow Accounting Users to access the newly created application and enable for example password.1
method or your preferred method for the application.
Tip | |||||
---|---|---|---|---|---|
The following OAuth2 client metadata describes a simple OAuth2 client that can request an access token using OAuth2 Resource Owner Password Credentials Grant
|
...
Add a user to Accounting Users group e.g. with the Management UI. You can choose from the following options:
...
Any of these actions can also be performed using the Management API.
Using Accounting API
Locate API scope
In order to access the Accounting API you need its client ID for the scope parameter of the OAuth2 Token Request. This client ID is visible in System → Accounting → Applications → Accounting as depicted here
Get the access token
Get the access token e.g. with OAuth2 Password grant. You may use the --insecure
flag in case self-signed certificates are used:
Code Block | ||
---|---|---|
| ||
$ curl \ --request POST 'https://<sso-base-url>/uas/oauth2/token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=password' \ --data-urlencode 'scope=openid <accounting-client-id>' \ --data-urlencode 'client_id=<oauth2-client-id>' \ --data-urlencode 'client_secret=<oauth2-client-secret>' \ --data-urlencode 'username=<accounting-api-user>' \ --data-urlencode 'password=<accounting-api-password>' |
Where:
Parameter | Description |
---|---|
accounting-client-id | The client_id of the Accounting OAuth2 application retrieved in Locate API scope section |
oauth2-client-id | The client_id of your OAuth2 client application you created in Creating a new OAuth2 application section |
oauth2-client-secret | The client_secret of your OAuth2 client application you created in Creating a new OAuth2 application section |
accounting-api-user | The username of the user you created in Define API user section |
accounting-api-user-password | The password of the user you created in Define API user section |
Using Accounting API
The Accounting API is documented using Swagger. You can access Swagger UI in https://<accounting-base-url>/swagger-ui/ by providing Accounting user credentials. Swagger documentation defines the endpoints, payloads, and responses. Note that the Swagger UI Try it out feature is not supported.
...
Request URL parameters
Path parameters
Parameter name | Description |
---|---|
period | The period of the time from which to return the events: MINUTE, HOUR, DAY, WEEK (7 days), MONTH - case insensitive. NOTE that you should choose such a period that produces a reasonable amount of events in the response so that you don't overuse resources. In typical installations, a period longer than a DAY is not recommended. It is better to make consecutive calls with a shorter period. See also |
datetime | Optional date/timestamp for the earliest events to include with ascending order or latest events to include with descending order. The required precision for the parameter depends on the given period. If not given, derived from the current time and given period.
The times are handled in UTC time zone so if you specify e.g. |
Query parameters
Parameter name | Description |
---|---|
sort | Sort direction, provide '-' for descending order by timestamp, otherwise ascending order by timestamp is used. |
Headers
Header name | Description |
---|---|
Authorization | Mandatory bearer token e.g. 'Authorization: Bearer eyJjdHkiOiJKV1Q...' (token truncated) |
Accept | Optional case insensitive media type for the response. If not provided or allows all media types, If CSV output is desired, media type Examples:
|
Curl example
You may use the --insecure
flag in case self-signed certificates are used. Add Accept
header with value 'Accept: text/csv, application/json'
for CSV output.
...
Response Document
JSON output
An EventDetailsResponse
object with NavigationLinks
and list of EventDetails
matching request parameters is returned (see Swagger API models for additional information)
...
When accepting JSON media type and an error happens an ErrorResponse
object is returned (see Swagger API models)
...
With JSON, if the streaming has already started with status code 200 and an error happens during processing, an error
element may be included to the EventDetailsResponse
.
With CSV, an error after streaming has started causes just end of streaming.
...