GLAPI.NET
1.1.12
dotnet add package GLAPI.NET --version 1.1.12
NuGet\Install-Package GLAPI.NET -Version 1.1.12
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GLAPI.NET" Version="1.1.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GLAPI.NET" Version="1.1.12" />
<PackageReference Include="GLAPI.NET" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GLAPI.NET --version 1.1.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GLAPI.NET, 1.1.12"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GLAPI.NET@1.1.12
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GLAPI.NET&version=1.1.12
#tool nuget:?package=GLAPI.NET&version=1.1.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
GLAPI.NET
A .NET client library for the GLPI API, supporting both the legacy REST API and the new high-level OAuth 2.0 API.
Features
- ✅ Support for Legacy REST API (App-Token and Session-Token authentication)
- ✅ Support for High-Level API (OAuth 2.0 authentication)
- ✅ Multiple authentication methods:
- Legacy API: Username/Password or User Token
- High-Level API: Password Grant, Authorization Code Grant, or Client Credentials Grant
- ✅ Comprehensive test coverage
- ✅ Built with .NET 9.0
Installation
dotnet add package GLAPI.NET
Quick Start
Using the Legacy API
using GLAPI.NET;
using GLAPI.NET.Configuration;
// Register services
var services = new ServiceCollection();
services.AddGlpiApi();
var serviceProvider = services.BuildServiceProvider();
// Create client factory
var factory = serviceProvider.GetRequiredService<GlpiClientFactory>();
// Configure Legacy API
var legacyConfig = new LegacyApiConfiguration
{
BaseUrl = "https://glpi.example.com",
AppToken = "your-app-token",
Username = "your-username",
Password = "your-password"
// OR use UserToken instead:
// UserToken = "your-user-token"
};
// Create and authenticate
var legacyClient = factory.CreateLegacyClient(legacyConfig);
var authenticated = await legacyClient.AuthenticateAsync();
if (authenticated)
{
Console.WriteLine($"Session Token: {legacyClient.Configuration.SessionToken}");
}
Using the High-Level API (OAuth 2.0)
using GLAPI.NET;
using GLAPI.NET.Configuration;
// Register services
var services = new ServiceCollection();
services.AddGlpiApi();
var serviceProvider = services.BuildServiceProvider();
// Create client factory
var factory = serviceProvider.GetRequiredService<GlpiClientFactory>();
// Configure High-Level API with Password Grant
var highLevelConfig = new HighLevelApiConfiguration
{
BaseUrl = "https://glpi.example.com",
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
GrantType = "password",
Username = "your-username",
Password = "your-password"
};
// Create and authenticate
var highLevelClient = factory.CreateHighLevelClient(highLevelConfig);
var authenticated = await highLevelClient.AuthenticateAsync();
if (authenticated)
{
Console.WriteLine($"Access Token: {highLevelClient.Configuration.AccessToken}");
Console.WriteLine($"Token Expires At: {highLevelClient.Configuration.TokenExpiresAt}");
}
Configuration Options
Legacy API Configuration
| Property | Required | Description |
|---|---|---|
BaseUrl |
Yes | The base URL of your GLPI instance |
AppToken |
Yes | Application token for API authentication |
Username |
Conditional | Username (required if using password auth) |
Password |
Conditional | Password (required if using password auth) |
UserToken |
Conditional | User token (alternative to username/password) |
SessionToken |
No | Automatically set after successful authentication |
High-Level API Configuration
| Property | Required | Description |
|---|---|---|
BaseUrl |
Yes | The base URL of your GLPI instance |
ClientId |
Yes | OAuth 2.0 client ID |
ClientSecret |
Yes | OAuth 2.0 client secret |
GrantType |
Yes | OAuth grant type: password, authorization_code, or client_credentials |
Username |
Conditional | Required for password grant type |
Password |
Conditional | Required for password grant type |
AuthorizationCode |
Conditional | Required for authorization_code grant type |
RedirectUri |
Conditional | Required for authorization_code grant type |
AccessToken |
No | Automatically set after successful authentication |
RefreshToken |
No | Automatically set after successful authentication |
TokenExpiresAt |
No | Automatically set after successful authentication |
Grant Types
Password Grant
Use username and password directly:
var config = new HighLevelApiConfiguration
{
BaseUrl = "https://glpi.example.com",
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
GrantType = "password",
Username = "your-username",
Password = "your-password"
};
Client Credentials Grant
For machine-to-machine authentication:
var config = new HighLevelApiConfiguration
{
BaseUrl = "https://glpi.example.com",
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
GrantType = "client_credentials"
};
Authorization Code Grant
For interactive authentication flows:
var config = new HighLevelApiConfiguration
{
BaseUrl = "https://glpi.example.com",
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
GrantType = "authorization_code",
AuthorizationCode = "authorization-code-from-oauth-flow",
RedirectUri = "https://your-app.com/callback"
};
Token Management
Checking Token Expiration (High-Level API)
var authenticator = new HighLevelApiAuthenticator(httpClient);
if (authenticator.IsTokenExpired(config, bufferSeconds: 60))
{
// Token is expired or about to expire, refresh it
await authenticator.RefreshTokenAsync(config);
}
Refreshing Tokens (High-Level API)
var authenticator = new HighLevelApiAuthenticator(httpClient);
var refreshed = await authenticator.RefreshTokenAsync(config);
if (refreshed)
{
Console.WriteLine("Token refreshed successfully");
}
Killing Sessions (Legacy API)
var authenticator = new LegacyApiAuthenticator(httpClient);
var killed = await authenticator.KillSessionAsync(config);
if (killed)
{
Console.WriteLine("Session killed successfully");
}
Testing
The library includes comprehensive unit tests and integration test support. To run the tests:
# Run all tests
dotnet test
# Run only unit tests (skip integration tests)
dotnet test --filter "Category!=Integration"
# Run only integration tests (requires GLPI instance configuration)
dotnet test --filter "Category=Integration"
Testing Against Your GLPI Instance
For testing against a real GLPI instance, see TESTING.md for detailed instructions on:
- Setting up credentials using environment variables
- Using .NET User Secrets for local development
- Running integration tests
- CI/CD integration examples
Building
dotnet build
Requirements
- .NET 9.0 or later
License
[Specify your license here]
Contributing
[Specify contribution guidelines here]
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.12 | 36 | 3/10/2026 |
| 1.1.11 | 32 | 3/10/2026 |
| 1.1.10 | 108 | 1/16/2026 |
| 1.1.8 | 99 | 1/16/2026 |
| 1.1.7 | 96 | 1/15/2026 |
| 1.1.6 | 97 | 1/15/2026 |
| 1.1.5 | 106 | 1/14/2026 |
| 1.1.4 | 107 | 1/5/2026 |
| 1.1.3 | 188 | 12/23/2025 |
| 1.1.2 | 194 | 12/23/2025 |
| 1.1.1 | 183 | 12/23/2025 |
| 1.1.0 | 278 | 12/17/2025 |
| 1.0.14 | 267 | 12/15/2025 |
| 1.0.13 | 275 | 12/15/2025 |
| 1.0.12 | 255 | 12/15/2025 |
| 1.0.11 | 143 | 12/12/2025 |
| 1.0.9 | 118 | 12/12/2025 |
| 1.0.8 | 123 | 12/12/2025 |
| 1.0.7 | 420 | 12/11/2025 |
| 1.0.6 | 424 | 12/11/2025 |
Loading failed