Authentication
Authentication
To interact with the METI API, you must first authenticate and obtain an access token. This token is required for all subsequent requests and ensures secure communication with the API.
Generate Token
To generate an authentication token, make a POST request to the /token
endpoint.
Request
URL:
https://api.meti.millpont.com/token
Method: POST
Headers:
Content-Type: application/json
Body Parameters:
email
(string): Your registered email address.password
(string): Your account password.
Response
token (string): The authentication token.
expires_in (integer): Token validity period in seconds.
Example Request
Example Response
Using the Token
Once you have obtained a token, include it in the Authorization
header of all API requests. The format is:
Example Request with Token
Handling Token Expiration in Automated Workflows
For workflows requiring long-term or large-scale API access, ensure your system can handle token expiration and renewal automatically.
Steps for Token Renewal
Track Token Expiration:
Use the
expires_in
field from the token response to calculate the token's expiry time.Store the token and its expiry timestamp securely.
Check Token Validity Before Each Request:
Compare the current time with the stored expiry timestamp.
If the token has expired or is close to expiring, retrieve a new token.
Automate Token Retrieval:
Implement logic to call the
/token
endpoint with your credentials when the token is invalid or expired.
Example Code Snippet (Python)
Benefits of Automation
Prevents downtime caused by expired tokens.
Ensures smooth and continuous API access for large-scale or time-sensitive operations.
Token Expiry
Tokens are valid for the duration specified in the expires_in
field of the response. If your token expires, you must request a new one by re-authenticating.
Common Errors
401 Unauthorized: This error occurs if the token is missing, invalid, or expired. Ensure you provide a valid token in the
Authorization
header.
By implementing automated token management, you can maintain uninterrupted API access, even for complex workflows.
Last updated