This document is designed to help you securely integrate our APIs with your systems using JSON Web Tokens (JWT) to ensure all communications are protected.
What is JWT?
JWT (JSON Web Tokens) is a method for representing claims securely between two parties. In the context of FieldEx, it enables secure exchange of user credentials and permissions between your application and our APIs, ensuring that each request is authenticated and authorized efficiently.
How JWT Works in FieldEx
JWT plays a critical role in securing communications between client applications and FieldEx APIs. Here’s how it is used:
- Token Creation: When a user logs in via your application's interface, FieldEx's authentication server validates the credentials and issues a JWT that includes user identification and role information.
- Token Transmission: This token must be included in the HTTP Authorization header as a Bearer token for every API call made to FieldEx.
- Token Validation: FieldEx's servers validate this token at the beginning of every API request to ensure it is valid and has not been tampered with.
- Session Management: JWTs are configured to expire automatically, necessitating re-authentication periodically, which enhances security.
Implementing JWT in FieldEx
Follow these steps to integrate JWT authentication into your application when interacting with FieldEx APIs.
Prerequisites
- Ensure your application can handle JWT libraries available for your development platform (e.g., Auth0, jsonwebtoken for Node.js).
- Use HTTPS to secure all communications between your application and FieldEx APIs.
Generating Tokens
Login API Endpoint
Request Body
{
"username": "exampleuser",
"password": "examplepassword"
}
Successful Response
{
"token": "generated.jwt.token.here"
}
Using Tokens
Include the JWT in the Authorization header with each request:
httpCopy codeAuthorization: Bearer
Validating Tokens
FieldEx handles the validation and renewal processes. Ensure your application gracefully handles scenarios where the token is expired or invalid, prompting re-authentication as necessary.
Security Considerations
To maximize security while using JWT with FieldEx:
- Keep your JWT secret keys confidential and secure.
- Rotate your keys periodically to mitigate potential security risks.
- Handle JWT expiry and renewal processes carefully to maintain uninterrupted access to FieldEx APIs.