- App-Token (optional) - Application-level authorization
- Session-Token (required) - User session identification
- User Token (alternative) - Personal access key
Authentication Flow
App-Token
The App-Token is an optional application-level authorization string that identifies your API client.Purpose
- Filter API access by application
- Track API usage per client
- Add an extra layer of security
- Restrict access by IP address per client
Configuration
- Navigate to Setup > General > API in ITSM-NG
- Create a new API client
- Configure:
- Name: Your application name
- Active: Yes
- IPv4 address range or IPv6 address: Allowed IPs
- Application token: Auto-generated or custom
Usage
Include the App-Token in the request header:Session Token
The Session-Token is a unique identifier for your authenticated session.Obtaining a Session Token
Call theinitSession endpoint with your credentials:
Method 1: User/Password Authentication
Authorization header uses HTTP Basic Authentication:
- Format:
Authorization: Basic base64(username:password) - Example:
glpi:glpibecomesZ2xwaTpnbHBpwhen base64 encoded
Login with credentials can be disabled in ITSM-NG configuration. If disabled, you must use a user_token instead.
Method 2: User Token Authentication
Response
Using Session Token
Include the Session-Token in all subsequent requests:While both header and query string methods work, using headers is recommended for better security.
Terminating a Session
Always terminate your session when finished:200 OK
User Token
The user_token is a personal access key that can be used instead of username/password.Finding Your User Token
- Log into ITSM-NG web interface
- Navigate to My Settings
- Go to the Remote access key tab
- Copy your personal API token
Using User Token
Advanced Session Options
Get Full Session
Retrieve complete session data during initialization:Session Write Mode
By default, API sessions are read-only to support parallel requests. Enable write mode when needed:Certain endpoints automatically enable write mode:
initSessionkillSessionchangeActiveEntitieschangeActiveProfile
Managing Profiles and Entities
Get My Profiles
Retrieve all profiles associated with your account:Change Active Profile
Get My Entities
Change Active Entities
Password Recovery
The API supports password reset functionality:Request Password Reset
This requires:
- Email notifications enabled in ITSM-NG
- Valid email address associated with a user account
Reset Password with Token
Security Best Practices
Use HTTPS in Production
Use HTTPS in Production
Always use HTTPS to encrypt API traffic and protect tokens in transit.
Rotate Tokens Regularly
Rotate Tokens Regularly
- Regenerate user_tokens periodically
- Update App-Tokens for compromised clients
- Implement token expiration policies
Restrict by IP Address
Restrict by IP Address
Configure API clients with specific IP ranges:
- Use IPv4 range:
192.168.1.0to192.168.1.255 - Or specific IPv6:
2001:db8::1
Terminate Sessions Properly
Terminate Sessions Properly
Always call
killSession when finished to prevent session hijacking:Limit Token Exposure
Limit Token Exposure
- Don’t log tokens in application logs
- Don’t commit tokens to version control
- Use environment variables for token storage
- Implement secure token storage mechanisms
Troubleshooting Authentication
ERROR_LOGIN_PARAMETERS_MISSING
Problem: Missing login credentials or user_token Solution: Provide either:loginandpasswordin Basic Auth header, ORuser_tokenin Authorization header
ERROR_LOGIN_WITH_CREDENTIALS_DISABLED
Problem: Login with username/password is disabled Solution: Use user_token authentication insteadERROR_GLPI_LOGIN_USER_TOKEN
Problem: Invalid user_token Solution:- Verify token in user settings
- Check for typos or extra spaces
- Regenerate token if necessary
ERROR_SESSION_TOKEN_MISSING
Problem: Session-Token not provided Solution: Include Session-Token header in all requests after initSessionERROR_SESSION_TOKEN_INVALID
Problem: Session token is invalid or expired Solution:- Call initSession again to get a new token
- Check if session was terminated
- Verify token wasn’t modified
ERROR_APP_TOKEN_PARAMETERS_MISSING
Problem: App-Token required but not provided Solution: Include App-Token in all requestsERROR_WRONG_APP_TOKEN_PARAMETER
Problem: App-Token doesn’t match configured value Solution:- Verify App-Token in ITSM-NG configuration
- Check API client settings
- Ensure correct token is being sent
ERROR_NOT_ALLOWED_IP
Problem: Your IP address is not authorized Solution:- Check API client IP configuration
- Verify your current IP address
- Update allowed IP ranges in ITSM-NG