{"id":18317890,"url":"https://github.com/idiocc/facebook","last_synced_at":"2025-08-11T09:17:09.117Z","repository":{"id":57117473,"uuid":"161145107","full_name":"idiocc/facebook","owner":"idiocc","description":"The Facebook OAuth Login Routes For The Idio Web Server.","archived":false,"fork":false,"pushed_at":"2018-12-13T19:21:34.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-06T02:47:01.394Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://idio.cc","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idiocc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-10T08:50:45.000Z","updated_at":"2018-12-31T01:51:03.000Z","dependencies_parsed_at":"2022-08-23T05:20:57.750Z","dependency_job_id":null,"html_url":"https://github.com/idiocc/facebook","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/idiocc/facebook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Ffacebook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Ffacebook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Ffacebook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Ffacebook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idiocc","download_url":"https://codeload.github.com/idiocc/facebook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Ffacebook/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269857731,"owners_count":24486396,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-05T18:07:47.900Z","updated_at":"2025-08-11T09:17:08.266Z","avatar_url":"https://github.com/idiocc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @idio/facebook\n\n[![npm version](https://badge.fury.io/js/%40idio%2Ffacebook.svg)](https://npmjs.org/package/@idio/facebook)\n\n`@idio/facebook` is The Facebook OAth Login Routes For The Idio Web Server.\n\n```sh\nyarn add -E @idio/facebook\n```\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [API](#api)\n- [`facebook(router: Router, config: Config)`](#facebookrouter-routerconfig-config-void)\n  * [`Config`](#type-config)\n  * [finish](#finish)\n- [Copyright](#copyright)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/0.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## API\n\nThe package is available by importing its default function:\n\n```js\nimport facebook from '@idio/facebook'\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/1.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## `facebook(`\u003cbr/\u003e\u0026nbsp;\u0026nbsp;`router: Router,`\u003cbr/\u003e\u0026nbsp;\u0026nbsp;`config: Config,`\u003cbr/\u003e`): void`\n\nSets up the `/auth/facebook` and `/auth/facebook/redirect` paths on the router to enable Facebook App Login. The `session` middleware needs to be installed to remember the `state`. The state is destroyed after the redirect.\n\n__\u003ca name=\"type-config\"\u003e`Config`\u003c/a\u003e__: Options for the program.\n\n|        Name        |             Type              |                                                                         Description                                                                          |         Default         |\n| ------------------ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------- |\n| __client_id*__     | _string_                      | The app's client id.                                                                                                                                         | -                       |\n| __client_secret*__ | _string_                      | The app's client secret.                                                                                                                                     | -                       |\n| path               | _string_                      | The server path to start the login flaw and use for redirect (`${path}/redirect`).                                                                           | `/auth/facebook`        |\n| scope              | _string_                      | The scope to ask permissions for.                                                                                                                            | -                       |\n| finish             | _(ctx, token, data) =\u0026gt; {}_ | The function to complete the authentication that receives the token and the data about the user, such as name and id. The default function redirects to `/`. | `setSession; redirect;` |\n\n```js\nimport facebook from '@idio/facebook'\nimport idioCore from '@idio/core'\n\nconst Server = async () =\u003e {\n  const { url, router, app } = await idioCore({\n    session: { use: true, keys: [process.env.SESSION_KEY || 'dev'] },\n    logger: { use: true },\n  }, { port: 5000 })\n  router.get('/', (ctx) =\u003e {\n    ctx.body = 'hello world'\n  })\n  facebook(router, {\n    client_id: process.env.CLIENT_ID,\n    client_secret: process.env.SECRET,\n    scope: 'manage_pages',\n\n  })\n  app.use(router.routes())\n  return { app, url }\n}\n```\n```\nhttp://localhost:5000 \n  \u003c-- GET /auth/facebook\n  --\u003e GET /auth/facebook 302 19ms 385b\n{ body: 'Redirecting to \u003ca href=\"https://www.facebook.com/dialog/oauth?client_id=273790443337044\u0026amp;redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fauth%2Ffacebook%2Fredirect\u0026amp;state=5190\u0026amp;scope=manage_pages\"\u003ehttps://www.facebook.com/dialog/oauth?client_id=273790443337044\u0026amp;redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fauth%2Ffacebook%2Fredirect\u0026amp;state=5190\u0026amp;scope=manage_pages\u003c/a\u003e.',\n  headers: \n   { location: 'https://www.facebook.com/dialog/oauth?client_id=273790443337044\u0026redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fauth%2Ffacebook%2Fredirect\u0026state=5190\u0026scope=manage_pages',\n     'content-type': 'text/html; charset=utf-8',\n     'content-length': '385',\n     'set-cookie': \n      [ 'koa:sess=eyJzdGF0ZSI6NTE5MCwiX2V4cGlyZSI6MTU0NDUyNTE1OTMzNCwiX21heEFnZSI6ODY0MDAwMDB9; path=/; httponly',\n        'koa:sess.sig=xhelrdB1iw6iAPnzfii_i9BTvF8; path=/; httponly' ],\n     date: 'Mon, 10 Dec 2018 10:45:59 GMT',\n     connection: 'close' },\n  statusCode: 302,\n  statusMessage: 'Found' }\n\n \u003e Redirect to Dialog https://www.facebook.com/dialog/oauth?client_id=273790443337044\u0026redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fauth%2Ffacebook%2Fredirect\u0026state=5190\u0026scope=manage_pages\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/2.svg?sanitize=true\" width=\"15\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n### finish\n\nThe config allows to set the `finish` function that can be used to alter the logic of setting the token on the session or performing additional operations such as storing a new user in the database. The default sets the token on the `ctx.session` and also sets the user data such as name and id in the `ctx.session.user` property.\n\n```js\n    finish = /* async */ (ctx, token, user, /* next */) =\u003e {\n      ctx.session.token = token\n      ctx.session.user = user\n      ctx.redirect('/')\n      // await storeInDb(token, user)\n      // await next()\n    },\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/3.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## Copyright\n\n(c) [Idio][1] 2018\n\n[1]: https://idio.cc\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/-1.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiocc%2Ffacebook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidiocc%2Ffacebook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiocc%2Ffacebook/lists"}