{"id":17855589,"url":"https://github.com/nebrius/express-facebook-auth","last_synced_at":"2025-07-20T13:33:06.902Z","repository":{"id":75505949,"uuid":"126530518","full_name":"nebrius/express-facebook-auth","owner":"nebrius","description":"A wrapper for express that simplifies some of the boilerplate for using Facebook for authentication","archived":false,"fork":false,"pushed_at":"2018-03-24T00:25:21.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-15T09:37:32.163Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/nebrius.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-23T19:28:32.000Z","updated_at":"2018-03-24T00:25:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"4ccb4e1f-efdf-46ae-80de-505e42be277e","html_url":"https://github.com/nebrius/express-facebook-auth","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.25,"last_synced_commit":"c5fdcb86bbb6aab0d0bd34b9a1ce3a359f3aea68"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nebrius/express-facebook-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebrius%2Fexpress-facebook-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebrius%2Fexpress-facebook-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebrius%2Fexpress-facebook-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebrius%2Fexpress-facebook-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nebrius","download_url":"https://codeload.github.com/nebrius/express-facebook-auth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nebrius%2Fexpress-facebook-auth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265982498,"owners_count":23859569,"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":[],"created_at":"2024-10-28T02:23:42.107Z","updated_at":"2025-07-20T13:33:06.885Z","avatar_url":"https://github.com/nebrius.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express Facebook Auth\n\nOpinionated Node.js authentication middleware for [express](http://expressjs.com/) that uses Facebook. By being opinionated, this module is relatively straightforward to use, as far as authentication is concerned. In all honestly, I mostly created this module because I was getting tired of copy-pasting the same code over and over :-P\n\n## Installation\n\n```Bash\nnpm install express-facebook-auth\n```\n## Example usage\n\nLet's start by creating a login page for our users called `login.pug`. This example uses the [Pug templating engine](https://pugjs.org/api/getting-started.html).\n\n```Pug\ndoctype html\nbody\n  a(href='https://www.facebook.com/v2.10/dialog/oauth?client_id=' + facebookAppId + '\u0026redirect_uri=' + redirectUri) Login with Facebook\n```\n\nThen, we create our express app:\n\n```JavaScript\nconst { Authenticator } = require('express-facebook-auth');\nconst express = require('express');\nconst cookieParser = require('cookie-parser');\n\nconst app = express();\napp.set('view engine', 'pug');\n\n// Cookie parser is Needed by express-facebook-auth to pass the Facebook\n// authentication token from the browser to this server\napp.use(cookieParser());\n\n// The login URI is used to specify the endpoint, relative to the `app` property\n// passed to `authenticator.createLoginSuccessEndpoint` method\nconst loginUri = '/login';\n\n// The redirect URI must be a fully qualified domain name, as this is passed to\n// Facebook from the browser, which it then uses to redirect the browser on its own\nconst redirectUri = 'http://myserver.net/login-success/';\n\nconst authenticator = new Authenticator({\n  facebookAppId: process.env.FACEBOOK_APP_ID,\n  facebookAppSecret: process.env.FACEBOOK_APP_SECRET,\n\n  // This callback is used to determine if the given Facebook user is allowed to\n  // access your system. By the time this method is called, the user has already\n  // been authenticated against Facebook. For this example, let's just say all\n  // Facebook users are registered with this server. In practice, you should have\n  // this method query your own user database to associate the Facebook ID with your user\n  isUserRegistered: (facebookId) =\u003e true,\n  loginUri,\n  redirectUri\n});\n\n// Render the login.pug file from above when a user navigates to http://myserver.net/login\napp.get(loginUri, (req, res) =\u003e {\n  res.render('login', {\n    facebookAppId: process.env.FACEBOOK_APP_ID,\n    redirectUri\n  });\n});\n\nauthenticator.createLoginSuccessEndpoint(app);\n\n// The boolean value passed to createMiddleware indicates whether or not a failed\n// login attempt should redirect back to `loginUri`, or return a 401 HTTP code. A\n// good rule of thumb is to set this to `true` for page URLs, and `false` for API\n// calls (i.e. XHR or Fetch calls)\napp.get('/', authenticator.createMiddleware(true), (req, res) =\u003e {\n  res.send('If you can see this, you are logged in!');\n});\n\napp.listen(3000, () =\u003e console.log('Example authenticated app listening on port 3000!'));\n```\n\n# License\n\nMIT License\n\nCopyright (c) 2018 Bryan Hughes \u003cbryan@nebri.us\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnebrius%2Fexpress-facebook-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnebrius%2Fexpress-facebook-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnebrius%2Fexpress-facebook-auth/lists"}