{ "id": "J3uKCCbSuQ1fdJkC", "name": "Audible Token Refresh", "nodes": [ { "parameters": { "rule": { "interval": [ { "triggerAtMinute": 3 } ] } }, "id": "schedule-trigger", "name": "Schedule Trigger", "position": [ 0, 0 ], "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.1 }, { "parameters": { "operation": "executeQuery", "query": "SELECT * FROM audible_credentials ORDER BY updated_at DESC LIMIT 1;", "additionalFields": {} }, "id": "get-credentials", "name": "Get Credentials", "position": [ 208, 0 ], "type": "n8n-nodes-base.postgres", "typeVersion": 1, "credentials": { "postgres": { "id": "9grzZwW7Br6SzdV8", "name": "n8n-media" } } }, { "parameters": { "jsCode": "// Encode raw_data to base64 for safe shell passing\nconst item = items[0];\nconst rawData = item.json.raw_data;\nconst base64Data = Buffer.from(JSON.stringify(rawData)).toString('base64');\nitem.json.creds_base64 = base64Data;\nreturn [item];" }, "id": "prepare-credentials", "name": "Prepare Credentials", "position": [ 400, 0 ], "type": "n8n-nodes-base.code", "typeVersion": 2 }, { "parameters": { "jsCode": "return JSON.parse($input.first().json.stdout);" }, "id": "parse-output", "name": "Parse Output", "position": [ 800, 0 ], "type": "n8n-nodes-base.code", "typeVersion": 2 }, { "parameters": { "authentication": "privateKey", "command": "=/home/b3nw/.local/bin/uv run setup_auth.py -json", "cwd": "/home/b3nw/projects/media/audible-script" }, "type": "n8n-nodes-base.ssh", "typeVersion": 1, "position": [ 608, 0 ], "id": "f858cc65-d12f-4b4f-8d49-03ba2a332b1c", "name": "Execute a command", "credentials": { "sshPrivateKey": { "id": "S2dcVMjrpg0I0kdV", "name": "vscode-dev.local.ben.io" } } }, { "parameters": { "operation": "update", "schema": { "__rl": true, "mode": "list", "value": "public" }, "table": { "__rl": true, "value": "audible_credentials", "mode": "list", "cachedResultName": "audible_credentials" }, "columns": { "mappingMode": "defineBelow", "value": { "access_token": "={{ $json.auth.access_token }}", "refresh_token": "={{ $json.auth.refresh_token }}", "id": 1, "raw_data": "={{ $json.auth }}", "expires_at": "={{ DateTime.fromSeconds($json.auth.expires).setZone('UTC').toFormat('yyyy-MM-dd HH:mm:ss.SSS') }}+00", "updated_at": "={{ $now.setZone('UTC').toFormat('yyyy-MM-dd HH:mm:ss.SSS') }}+00" }, "matchingColumns": [ "id" ], "schema": [ { "id": "id", "displayName": "id", "required": false, "defaultMatch": true, "display": true, "type": "number", "canBeUsedToMatch": true, "removed": false }, { "id": "access_token", "displayName": "access_token", "required": true, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "refresh_token", "displayName": "refresh_token", "required": true, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true }, { "id": "expires_at", "displayName": "expires_at", "required": false, "defaultMatch": false, "display": true, "type": "dateTime", "canBeUsedToMatch": true }, { "id": "raw_data", "displayName": "raw_data", "required": false, "defaultMatch": false, "display": true, "type": "object", "canBeUsedToMatch": true }, { "id": "updated_at", "displayName": "updated_at", "required": false, "defaultMatch": false, "display": true, "type": "dateTime", "canBeUsedToMatch": true } ], "attemptToConvertTypes": false, "convertFieldsToString": false }, "options": {} }, "type": "n8n-nodes-base.postgres", "typeVersion": 2.6, "position": [ 976, 0 ], "id": "be8ac7c8-c6ee-464c-8483-421f0959dae6", "name": "Update rows in a table", "credentials": { "postgres": { "id": "9grzZwW7Br6SzdV8", "name": "n8n-media" } } } ], "connections": { "Get Credentials": { "main": [ [ { "index": 0, "node": "Prepare Credentials", "type": "main" } ] ] }, "Parse Output": { "main": [ [ { "node": "Update rows in a table", "type": "main", "index": 0 } ] ] }, "Prepare Credentials": { "main": [ [ { "node": "Execute a command", "type": "main", "index": 0 } ] ] }, "Schedule Trigger": { "main": [ [ { "index": 0, "node": "Get Credentials", "type": "main" } ] ] }, "Execute a command": { "main": [ [ { "node": "Parse Output", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1", "saveDataErrorExecution": "all", "saveDataSuccessExecution": "all", "saveManualExecutions": true, "saveExecutionProgress": true, "callerPolicy": "workflowsFromSameOwner", "availableInMCP": false }, "triggerCount": 1, "versionId": "6b85905f-aa69-42b8-a224-520c4f32ae29", "owner": { "type": "personal", "projectId": "FeLO36wNUAcn61Wj", "projectName": "Ben W ", "personalEmail": "admin@ben.io" }, "parentFolderId": "of8yoeyjjIAhYdnQ", "isArchived": false }