Clone
2
Home
Jason SECULA edited this page 2026-03-19 18:58:39 +00:00

How to use

1. Initializing the GLPIAPI object

To establish a connection to your GLPI instance using the GLPIAPI module, instantiate the GLPIAPI class with the required configuration parameters.

Example Usage

from GLPIAPI.GLPIAPI import GLPIAPI

# Create a GLPI API connector
glpiConnector = GLPIAPI(
   Server="http://glpi-server.local",
   AppToken="AnAppTokenHere",
   UserToken="AnUserTokenHere",
   UserAgent="GLPI Connector"
)

⚙️ Parameters

Parameter Type Required Description
server str Yes The base URL of your GLPI instance (e.g., http://glpi-server.local).
app_token str Yes A valid application token. This token is required to uses the GLPI API.
user_token str Yes A valid user token for authenticated access. This allows the connector to act on behalf of a specific user.
user_agent str No Optional. A custom user agent string to identify your application when updating inventories. Defaults to "GLPI API".

🔐Session Behavior

When the GLPIAPI connector is initialized, it establishes a secure session with the GLPI server by authenticating using the provided application and user tokens. This authentication results in a session token that is automatically managed by the connector. The session remains active until it expires, based on the session.gc_maxlifetime parameter in your PHP configuration.

To reconnect after session expiration, the GLPIAPI connector must be reinitialized with the same credentials. The connector does not automatically refresh the session or retry authentication — a new instance with valid tokens is required to restore access.