{
  "name": "Automatic Google Cloud Run auth with JWT token management (sub-workflow)",
  "nodes": [
    {
      "id": "4cb478c7-57e8-4028-a39c-0a47cd3edb0a",
      "name": "If Token",
      "type": "n8n-nodes-base.if",
      "position": [
        224,
        544
      ]
    },
    {
      "id": "30a6ed20-9f0a-481f-825a-47affdc14a90",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        608,
        416
      ]
    },
    {
      "id": "27cebdb1-e3c5-445c-99fe-421b43a8535b",
      "name": "Return Values",
      "type": "n8n-nodes-base.set",
      "position": [
        1232,
        560
      ]
    },
    {
      "id": "1ff1b7b4-69d1-45de-bdc3-425781ac4fda",
      "name": "Combine Context",
      "type": "n8n-nodes-base.merge",
      "position": [
        0,
        544
      ]
    },
    {
      "id": "dd9fbe7d-c064-40be-9afe-bd1c65844c4c",
      "name": "Raise Id",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        400
      ]
    },
    {
      "id": "e15593e0-3831-4642-83a4-f1262a781c43",
      "name": "Decode JWT",
      "type": "n8n-nodes-base.jwt",
      "position": [
        416,
        416
      ]
    },
    {
      "id": "cc318a16-9e8e-4b8c-a9dc-518b4119e783",
      "name": "Sign New JWT",
      "type": "n8n-nodes-base.jwt",
      "position": [
        784,
        560
      ]
    },
    {
      "id": "9dfe02d4-ca20-449f-98af-98233233f54f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        192
      ],
      "parameters": {
        "width": 400,
        "height": 496,
        "content": "## Google Service Auth Workflow\n\n## **Purpose**\nHandles Google Cloud authentication with automatic token refresh. Checks if existing token is valid before requesting new one.\n\n## **How It Works**\n1. R"
      }
    },
    {
      "id": "ff9df5f7-eac1-449e-b772-e5e8ec029623",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -16
      ],
      "parameters": {
        "width": 304,
        "height": 512,
        "content": "## Using This Workflow\n\n### **As Sub-Workflow**\nCall from main workflow using Execute Workflow node:\n* Optional Input: `id_token` (for reuse)\n* Returns: Fresh or validated token\n\n### **Token Logic**\n*"
      }
    },
    {
      "id": "f99ed6c6-01a2-480e-bc89-508c098b951a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        0
      ],
      "parameters": {
        "width": 256,
        "height": 384,
        "content": "## Key Features\n### **Automatic Validation**\n* Decodes JWT to check expiration\n* No unnecessary API calls\n* Reduces quota usage\n### **Error Prevention**\n* 5-minute expiration buffer\n* Prevents mid-wor"
      }
    },
    {
      "id": "2e0584c6-8628-49db-b2fa-6ae7488cff41",
      "name": "Start",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -448,
        560
      ]
    },
    {
      "id": "1995c7ce-b6ca-4c99-b683-73c2fa7581f8",
      "name": "Bearer YOUR_TOKEN_HERE Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1008,
        560
      ]
    },
    {
      "id": "d98fd0cd-cd67-4290-9aa1-d0cbf8d98bb9",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        352
      ],
      "parameters": {
        "width": 166,
        "height": 240,
        "content": "#### Var Config\n- **client_email** - from `.json key`"
      }
    },
    {
      "id": "2c38cc10-1c06-45fc-8283-3a4f3afede0e",
      "name": "Vars",
      "type": "n8n-nodes-base.set",
      "position": [
        -224,
        448
      ]
    },
    {
      "id": "ff91e405-5cdc-4857-bc83-166a18342c64",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        544
      ],
      "parameters": {
        "width": 230,
        "height": 432,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n### Create a JWT Credential\n\nUse the **private_key** from your generated `.json key` file.\n\n- **Key Type:** PEM Key  \n- **Private Key:** `private_key` (full block, including `-----BEGIN P"
      }
    },
    {
      "id": "2f44ed65-9dbe-4713-9153-3c9e49893d19",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        -32
      ],
      "parameters": {
        "width": 672,
        "height": 208,
        "content": "## Required Setup — Google Cloud Run & Service Account\n### You’ll need to:\n- **Configure a Google Cloud Run service** (set **Require authentication**).\n- **Create a Google Service Account** and grant "
      }
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Raise Id",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sign New JWT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vars": {
      "main": [
        [
          {
            "node": "Combine Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "Combine Context",
            "type": "main",
            "index": 1
          },
          {
            "node": "Vars",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Token": {
      "main": [
        [
          {
            "node": "Decode JWT",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sign New JWT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Raise Id": {
      "main": [
        [
          {
            "node": "Return Values",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Decode JWT": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sign New JWT": {
      "main": [
        [
          {
            "node": "Bearer YOUR_TOKEN_HERE Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Context": {
      "main": [
        [
          {
            "node": "If Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bearer Token Request": {
      "main": [
        [
          {
            "node": "Return Values",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}