OK. . .I am building a custom app and I am having difficulty with the connection. The API is simple, and it uses an API key to generate a session key for all subsequent requests.
However, there is no expiration information on the session key that is generated. So, I created my own expiration, but the connection is NOT renewing the key. I have to manually click on Verify in the connection to fix it.
Here’s my Connection code:
{
// ****************************
// * API REQUEST *
// ****************************
// URL for the API request, dynamically set based on environment parameters.
"url": "https://{{parameters.environment}}.qliqsoft.com/quincy_api/v1/session",
// HTTP method used for the request.
"method": "POST",
// ****************************
// * HEADERS *
// ****************************
"headers": {
// Authorization header with API key for authentication.
"Authorization": "{{parameters.apiKey}}"
},
// ****************************
// * RESPONSE HANDLING *
// ****************************
"response": {
"data": {
// Stores the session key from the response for future API calls.
"sessionKey": "{{body.session_key}}",
// Sets session expiration time (current time + 3600 seconds = 1 hour).
"expires": "{{addSeconds(now, 3600)}}"
},
"metadata": {
// Specifies the type of metadata (either "text" or "email") for the connection label.
"type": "email",
// Displays the authorized user's email in the connection label (not functional yet).
"value": "{{body.user.email}}"
},
"error": {
// Formats error messages as "[statusCode] error text" for debugging.
"message": "[{{statusCode}}] {{body.error}}"
}
},
// ****************************
// * SESSION REFRESH LOGIC *
// ****************************
"refresh": {
// Re-authentication URL, same as initial request.
"url": "https://{{parameters.environment}}.qliqsoft.com/quincy_api/v1/session",
"method": "POST",
"headers": {
// Authorization using API key for refreshing the session.
"Authorization": "{{parameters.apiKey}}"
},
"response": {
"data": {
// Refreshes session key and resets expiration time.
"sessionKey": "{{body.session_key}}",
"expires": "{{addSeconds(now, 3600)}}"
},
"error": {
// Handles error messages during session refresh.
"message": "[{{statusCode}}] {{body.error}}"
}
}
},
// HTTP status codes that trigger automatic session refresh.
"refreshOn": [401, 403],
// ****************************
// * LOGGING *
// ****************************
"log": {
"sanitize": [
// Excludes the "Authorization" header from logs to protect sensitive data.
"request.headers.authorization"
]
}
}
And here is my parameters code:
[
// ****************************
// * API AUTHENTICATION *
// ****************************
{
// Description: API Key required for authentication.
// Instructs the user where to obtain the API key.
"help": "Your Quincy API Key acquired from the admin dashboard.",
// Internal name used for referencing this parameter.
"name": "apiKey",
// Type of input field (password field hides input for security).
"type": "password",
// User-friendly label for display in the UI.
"label": "API Key",
// Allows user to modify this value after initial setup.
"editable": true,
// This field is mandatory for authentication.
"required": true
},
// ****************************
// * ENVIRONMENT SETUP *
// ****************************
{
// Instructs the user which app environment to connect to (e.g., production or sandbox).
"help": "The environment to which you will connect.",
// Internal name used for referencing this parameter.
"name": "environment",
// Type of input field (plain text).
"type": "text",
// User-friendly label for display in the UI.
"label": "Environment",
// This field is required for establishing a connection.
"required": true,
// Allows user to modify this value after initial setup.
"editable": true,
// Default environment value (e.g., "capi" as the default connection point).
"default": "capi"
}
]
Am I just doing something stupid? I can’t understand why the Connection is not refreshing unless I manually click on Verify.