{"id":18539069,"url":"https://github.com/simov/grant-gcloud","last_synced_at":"2026-03-19T04:58:24.604Z","repository":{"id":66028224,"uuid":"282792360","full_name":"simov/grant-gcloud","owner":"simov","description":"Google Cloud Function handler for Grant","archived":false,"fork":false,"pushed_at":"2021-01-04T09:44:16.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-15T02:13:49.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-07-27T04:17:54.000Z","updated_at":"2023-03-04T06:05:03.000Z","dependencies_parsed_at":"2023-04-03T19:02:40.084Z","dependency_job_id":null,"html_url":"https://github.com/simov/grant-gcloud","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/simov/grant-gcloud","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-gcloud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-gcloud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-gcloud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-gcloud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simov","download_url":"https://codeload.github.com/simov/grant-gcloud/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-gcloud/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28725622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-06T19:46:07.076Z","updated_at":"2026-01-24T11:06:01.869Z","avatar_url":"https://github.com/simov.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# grant-gcloud\n\n\u003e _Google Cloud Function handler for **[Grant]**_\n\n```js\nvar grant = require('grant').gcloud({\n  config: {/*configuration - see below*/}, session: {name: '__session', secret: 'grant'}\n})\n\nexports.handler = async (req, res) =\u003e {\n  var {response} = await grant(req, res)\n  if (response) {\n    res.statusCode = 200\n    res.setHeader('content-type', 'application/json')\n    res.end(JSON.stringify(response))\n  }\n}\n```\n\n\u003e _Also available for [AWS], [Azure], [Vercel]_\n\n\u003e _[ES Modules and TypeScript][grant-types]_\n\n---\n\n## Configuration\n\nThe `config` key expects your [**Grant** configuration][grant-config].\n\n## Routes\n\nGrant relies on the request path to determine the provider name and any static override being used.\n\nAdditionally the `prefix` specified in your Grant configuration, that defaults to `/connect`, is used to generate the correct `redirect_uri` in case it is not configured explicitly.\n\n### Default Domain\n\n```\nhttps://[REGION]-[PROJECT].cloudfunctions.net/[LAMBDA]/connect/google\nhttps://[REGION]-[PROJECT].cloudfunctions.net/[LAMBDA]/connect/google/callback\n```\n\nYou have to specify the `redirect_uri` explicitly because the actual request URL contains the lambda name in the path, but that is never sent to your lambda handler:\n\n```json\n{\n  \"defaults\": {\n    \"origin\": \"https://[REGION]-[PROJECT].cloudfunctions.net\"\n  },\n  \"google\": {\n    \"redirect_uri\": \"https://[REGION]-[PROJECT].cloudfunctions.net/[LAMBDA]/connect/google/callback\"\n  }\n}\n```\n\n### Firebase Hosting\n\nIn case you have the following `rewrites` configuration that proxy all requests to your `grant` handler:\n\n```json\n{\n  \"hosting\": {\n    ...\n    \"rewrites\": [\n      {\n        \"source\": \"**\",\n        \"function\": \"grant\"\n      }\n    ]\n  }\n}\n```\n\n```\nhttps://[PROJECT].firebaseapp.com/connect/google\nhttps://[PROJECT].firebaseapp.com/connect/google/callback\n```\n\n```json\n{\n  \"defaults\": {\n    \"origin\": \"https://[PROJECT].firebaseapp.com\"\n  },\n  \"google\": {}\n}\n```\n\n---\n\n## Local Routes\n\nWhen running locally the following routes can be used:\n\n```\nhttp://localhost:3000/connect/google\nhttp://localhost:3000/connect/google/callback\n```\n\n---\n\n## Session\n\nThe `session` key expects your session configuration:\n\nOption | Description\n:- | :-\n`name` | Cookie name, defaults to `grant`, **it have to be set to `__session` for Firebase Hosting!**\n`secret` | Cookie secret, **required**\n`cookie` | [cookie] options, defaults to `{path: '/', httpOnly: true, secure: false, maxAge: null}`\n`store` | External session store implementation\n\n#### NOTE:\n\n- The default cookie store is used unless you specify a `store` implementation!\n- Using the default cookie store **may leak private data**!\n- Implementing an external session store is recommended for production deployments!\n\nExample session store implementation using [Firebase]:\n\n```js\nvar request = require('request-compose').client\n\nvar path = process.env.FIREBASE_PATH\nvar auth = process.env.FIREBASE_AUTH\n\nmodule.exports = {\n  get: async (sid) =\u003e {\n    var {body} = await request({\n      method: 'GET', url: `${path}/${sid}.json`, qs: {auth},\n    })\n    return body\n  },\n  set: async (sid, json) =\u003e {\n    await request({\n      method: 'PATCH', url: `${path}/${sid}.json`, qs: {auth}, json,\n    })\n  },\n  remove: async (sid) =\u003e {\n    await request({\n      method: 'DELETE', url: `${path}/${sid}.json`, qs: {auth},\n    })\n  },\n}\n```\n\n---\n\n## Handler\n\nThe Google Cloud Funtion handler for Grant accepts:\n\nArgument | Type | Description\n:- | :- | :-\n`req` | **required** | The request object\n`res` | **required** | The response object\n`state` | optional | [Dynamic State][grant-dynamic-state] object `{dynamic: {..Grant configuration..}}`\n\nThe Google Cloud Funtion handler for Grant returns:\n\nParameter | Availability | Description\n:- | :- | :-\n`session` | Always | The session store instance, `get`, `set` and `remove` methods can be used to manage the Grant session\n`redirect` | On redirect only | HTTP redirect controlled by Grant, it is set to `true` when Grant is going to handle the redirect internally\n`response` | Based on transport | The [response data][grant-response-data], available for [transport-state][example-transport-state] and [transport-session][example-transport-session] only\n\n---\n\n## Examples\n\nExample | Session | Callback λ\n:- | :- | :-\n`transport-state` | Cookie Store | ✕\n`transport-querystring` | Cookie Store | ✓\n`transport-session` | Firebase Session Store | ✓\n`dynamic-state` | Firebase Session Store | ✕\n\n\u003e _Different session store types were used for example purposes only._\n\n#### Configuration\n\nAll variables at the top of the [`Makefile`][example-makefile] with value set to `...` have to be configured:\n\n- `project` - Project ID\n- `account.json` - Project Service Account Credentials\n\n- `firebase_path` - [Firebase] path of your database, required for [transport-session][example-transport-session] and [dynamic-state][example-dynamic-state] examples\n\n```\nhttps://[project].firebaseio.com/[prefix]\n```\n\n- `firebase_auth` - [Firebase] auth key of your database, required for [transport-session][example-transport-session] and [dynamic-state][example-dynamic-state] examples\n\n```json\n{\n  \"rules\": {\n    \".read\": \"auth == '[key]'\",\n    \".write\": \"auth == '[key]'\"\n  }\n}\n```\n\nAll variables can be passed as arguments to `make` as well:\n\n```bash\nmake plan example=transport-querystring ...\n```\n\n---\n\n## Develop\n\n```bash\n# build example locally\nmake build-dev\n# run example locally\nmake run-dev\n```\n\n---\n\n## Deploy\n\n```bash\n# build Grant lambda for deployment\nmake build-grant\n# build callback lambda for transport-querystring and transport-session examples\nmake build-callback\n# execute only once\nmake init\n# plan before every deployment\nmake plan\n# apply plan for deployment\nmake apply\n# cleanup resources\nmake destroy\n```\n\n---\n\n  [Grant]: https://github.com/simov/grant\n  [AWS]: https://github.com/simov/grant-aws\n  [Azure]: https://github.com/simov/grant-azure\n  [Google Cloud]: https://github.com/simov/grant-gcloud\n  [Vercel]: https://github.com/simov/grant-vercel\n\n  [cookie]: https://www.npmjs.com/package/cookie\n  [Firebase]: https://firebase.google.com/\n\n  [grant-config]: https://github.com/simov/grant#configuration\n  [grant-dynamic-state]: https://github.com/simov/grant#dynamic-state\n  [grant-response-data]: https://github.com/simov/grant#callback-data\n  [grant-types]: https://github.com/simov/grant#misc-es-modules-and-typescript\n\n  [example-makefile]: https://github.com/simov/grant-gcloud/tree/master/Makefile\n  [example-transport-state]: https://github.com/simov/grant-gcloud/tree/master/examples/transport-state\n  [example-transport-querystring]: https://github.com/simov/grant-gcloud/tree/master/examples/transport-querystring\n  [example-transport-session]: https://github.com/simov/grant-gcloud/tree/master/examples/transport-session\n  [example-dynamic-state]: https://github.com/simov/grant-gcloud/tree/master/examples/dynamic-state\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimov%2Fgrant-gcloud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimov%2Fgrant-gcloud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimov%2Fgrant-gcloud/lists"}