The Modaltrans API requires JWT Bearer tokens for authentication, which are obtained using valid login credentials. If the credentials are incorrect, the API will return a '403 Forbidden' error. Tokens are valid for one hour, after which a new token must be generated. You may also obtain a new token before each request if needed.Security Considerations#
When interacting with the Modaltrans API using JWT Bearer tokens, it's important to follow these security best practices to protect your application and data:Securely Store the JWT Token
Once you receive a JWT Bearer token from the Modaltrans API, ensure it is stored securely. Do not store the token in places accessible to JavaScript, such as local storage or session storage.
Token Expiry and Rotation
JWT tokens provided by the Modaltrans API have a limited validity period (typically one hour). Make sure to handle token expiry in your application by refreshing the token before it expires or requesting a new token when necessary. This ensures continuous and secure access to the API.
Do Not Share Your JWT Token
Treat your JWT token like a password. Do not share it publicly or hard-code it in client-side code, as this could allow unauthorized access to your API.
By following these security considerations, you can help ensure that JWTs are used safely and effectively within your applications.Authentication error response#
When interacting with the Modaltrans API, authentication is a crucial step. If the API detects issues with the provided login credentials, you will receive an HTTP 403 Forbidden response. This status code indicates that the request was valid, but the server is refusing to fulfill it due to authentication issues.Possible Causes of HTTP 403 Response:#
Incorrect Credentials: The username or password provided is incorrect.
Missing Credentials: The required authentication information is not included in the request.
Malformed Credentials: The format of the credentials is incorrect or not as expected.
Example of an Authentication Error Response#
When an authentication error occurs, the API response will include details about the failure. Below is an example of a typical error response when invalid login credentials are provided:How to Handle Authentication Errors:#
Verify Credentials: Double-check that the credentials being sent are correct and formatted properly. Ensure that any required fields are not missing.
Check Token Validity: If using a JWT Bearer token, ensure that the token is valid, not expired, and correctly formatted.
Modified at 2024-09-09 13:25:59