{"id":19584839,"url":"https://github.com/flex-development/fct-api","last_synced_at":"2025-06-23T08:39:47.193Z","repository":{"id":114011198,"uuid":"335392432","full_name":"flex-development/fct-api","owner":"flex-development","description":"Generate custom tokens for Firebase via API endpoint. API usage tracked with Google Analytics.","archived":false,"fork":false,"pushed_at":"2023-03-05T20:24:02.000Z","size":2376,"stargazers_count":0,"open_issues_count":10,"forks_count":0,"subscribers_count":3,"default_branch":"next","last_synced_at":"2025-02-26T12:43:10.498Z","etag":null,"topics":["firebase","firebase-admin","firebase-auth","google-analytics","measurement-protocol","serverless","serverless-api","serverless-functions","vercel"],"latest_commit_sha":null,"homepage":"https://fct-api.flexdevelopment.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flex-development.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-02T18:56:00.000Z","updated_at":"2021-02-19T15:43:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"a52e2e79-dc5d-432c-b02f-8179e5f9f2ed","html_url":"https://github.com/flex-development/fct-api","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/flex-development/fct-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Ffct-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Ffct-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Ffct-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Ffct-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flex-development","download_url":"https://codeload.github.com/flex-development/fct-api/tar.gz/refs/heads/next","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Ffct-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259712380,"owners_count":22900036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["firebase","firebase-admin","firebase-auth","google-analytics","measurement-protocol","serverless","serverless-api","serverless-functions","vercel"],"created_at":"2024-11-11T07:50:17.529Z","updated_at":"2025-06-13T20:05:31.782Z","avatar_url":"https://github.com/flex-development.png","language":"TypeScript","readme":"# Firebase Custom Token API\n\nCreate custom tokens for Firebase via API endpoint\n\n[![TypeScript](https://badgen.net/badge/-/typescript?icon=typescript\u0026label)](https://www.typescriptlang.org/)\n\n## Overview\n\n[Getting Started](#getting-started)  \n[Usage](#usage)  \n[Built With](#built-with)  \n[Contributing](docs/CONTRIBUTING.md)  \n[Deployment](docs/DEPLOYMENT.md)\n\n## Getting Started\n\nThe Firebase Custom Token (FCT) API is a single serverless endpoint that can be\nused to generate custom tokens for Firebase.\n\nFor more information, see [Create Custom Tokens][1] from the Firebase docs.\n\n## Usage\n\n### Authorization\n\nThe `headers` field of every request should include the following keys:\n\n- `client_email`\n- `private_key`\n- `project_id`\n\n![FCT API - Headers](./docs/fct-api-headers.png)\n\nThe required keys can be found by generating a private key file from the\nFirebase Console:\n\n1. Open **Settings \u003e Service Accounts**\n2. Click **Generate New Private Key**; confirm by clicking **Generate Key**\n3. Securely store the JSON file containing the key\n\n### Create Custom Token\n\nGenerate a custom token for a single user or batch of users, as well as\noptionally specify additional claims to be included in each token.\n\n- **URL**: `https://fct-api.flexdevelopment.vercel.app`\n- **Method**: `POST`\n\n#### Query Parameters\n\n| name              | type      | default | required | description                                         |\n| ----------------- | --------- | ------- | -------- | --------------------------------------------------- |\n| `user_must_exist` | `boolean` | `true`  | `false`  | check if user exists before generating custom token |\n\n#### Request Body\n\nThe `body` of every request should have the following shape:\n\n```json\n[\n  {\n    \"uid\": 20430108\n  }\n]\n```\n\nCustom claims can also be specified for each user:\n\n```json\n[\n  {\n    \"developerClaims\": {\n      \"admin\": true\n    },\n    \"uid\": 20430108\n  }\n]\n```\n\n#### Sample Response\n\n#### Default\n\n![FCT API - Success Response](./docs/fct-api-response-success.png)\n\n#### With `developerClaims`\n\n![FCT API - Success Response 2](./docs/fct-api-response-success-with-claims.png)\n\n#### With `user_must_exist: false`\n\n![FCT API - Success Response 3](./docs/fct-api-response-success-with-query.png)\n\n### Errors\n\nIf an error is thrown, it will have the following shape:\n\n```json\n{\n  \"name\": \"GeneralError\",\n  \"message\": \"\",\n  \"code\": 500,\n  \"className\": \"general-error\",\n  \"data\": {\n    \"body\": \"\",\n    \"query\": {\n      \"compile\": true,\n      \"options\": {}\n    }\n  },\n  \"errors\": {}\n}\n```\n\n#### 404 Sample\n\n```json\n{\n  \"name\": \"NotFound\",\n  \"message\": \"There is no user record corresponding to the provided identifier.\",\n  \"code\": 404,\n  \"className\": \"not-found\",\n  \"data\": {\n    \"codePrefix\": \"auth\",\n    \"req\": {\n      \"body\": [\n        {\n          \"uid\": -1\n        }\n      ],\n      \"query\": {\n        \"user_must_exist\": true\n      }\n    }\n  },\n  \"errors\": {\n    \"code\": \"auth/user-not-found\",\n    \"uid\": -1\n  }\n}\n```\n\n## Built With\n\n- [Firebase Admin][2] - Interact with Firebase from privileged environments\n- [Vercel][3] - Hosting platform for serverless functions\n\n[1]: https://firebase.google.com/docs/auth/admin/create-custom-tokens\n[2]: https://firebase.google.com/docs/admin/setup\n[3]: https://vercel.com/docs/serverless-functions/introduction\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Ffct-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflex-development%2Ffct-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Ffct-api/lists"}