{
  "slug": "github-api-private-token-proxy",
  "title": "Call Github API with Private Personal Access Token from Client",
  "metaTitle": "Call Github API with Private - RealComposer",
  "metaDescription": "Call github api with private personal access token from client. Keep GitHub keys in RealComposer Vault; Frontend / Web uses rc_live_ tokens only.",
  "headline": "GitHub secrets stay out of Frontend / Web bundles",
  "category": "security",
  "categoryLabel": "Security & Secret Vault",
  "urgency": 9,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "GitHub"
  ],
  "searchIntentQuery": "call github api with private personal access token from client",
  "directAnswerSummary": "Frontend / Web cannot safely store GitHub production keys. Vault-bound headers reach https://api.github.com/user/repos?per_page=5 on Workers while apps call your github-api-private-token-proxy edge URL.",
  "problem": {
    "title": "Why Frontend / Web leaks GitHub credentials",
    "explanation": "Attackers routinely extract GitHub secrets from Frontend / Web builds. Direct browser calls also expose internal error payloads with hostnames.",
    "risks": [
      "Production GitHub keys copied from Frontend / Web bundles",
      "Compliance violations after credential leaks",
      "Attackers replaying vault-grade scopes from a laptop"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Add vault secrets for this pipeline",
      "description": "Store GITHUB_TOKEN in the vault. Frontend / Web never embeds the raw secret, only a revocable rc_live_ client token."
    },
    {
      "stepNumber": 2,
      "title": "Target the real upstream URL",
      "description": "Configure headersTemplate to inject vault secrets, target https://api.github.com/user/repos?per_page=5, and Add output mapping fields that mirror the JSON contract your screen already expects."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Allowed origins on the token should list every Frontend / Web host that calls this URL.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/github-api-private-token-proxy', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Call Github API with Private Personal Access Token from Client",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "github",
        "upstreamUrlTemplate": "https://api.github.com/user/repos?per_page=5",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.GITHUB_TOKEN}}",
          "Accept": "application/vnd.github+json"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "repoId",
          "sourcePath": "0.id",
          "type": "number",
          "sourceStep": "github"
        },
        {
          "targetPath": "fullName",
          "sourcePath": "0.full_name",
          "type": "string",
          "sourceStep": "github"
        },
        {
          "targetPath": "isPrivate",
          "sourcePath": "0.private",
          "type": "boolean",
          "sourceStep": "github"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_github-a",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "github-api-private-token-proxy"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "repoId": "sample",
    "fullName": "sample",
    "isPrivate": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/github-api-private-token-proxy\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "Can Frontend / Web call GitHub without holding the production key?",
      "answer": "Use scoped tokens where the vendor allows them on github-api-private-token-proxy. Admin keys stay {{secrets.*}} references only."
    },
    {
      "question": "How do I forward JSON bodies to POST upstreams?",
      "answer": "github-api-private-token-proxy keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache."
    },
    {
      "question": "How do I rotate upstream credentials?",
      "answer": "Rotate vault secrets for github-api-private-token-proxy anytime; clients keep the same rc_live_ token."
    }
  ],
  "relatedRecipeSlugs": [
    "combine-intercom-and-zendesk-support-api",
    "zero-code-api-gateway-indie-hackers",
    "slim-github-api-response-mobile-widgets"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/github-api-private-token-proxy",
    "markdown": "https://realcomposer.com/recipes/github-api-private-token-proxy.md",
    "json": "https://realcomposer.com/recipes/github-api-private-token-proxy.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=github-api-private-token-proxy&via=agent"
  }
}