{"id":28438095,"url":"https://github.com/parse-community/parse-facebook-user-session","last_synced_at":"2025-06-28T15:31:36.014Z","repository":{"id":23295801,"uuid":"26655019","full_name":"parse-community/parse-facebook-user-session","owner":"parse-community","description":"A Cloud Code module to facilitate logging into an express website with Facebook.","archived":false,"fork":false,"pushed_at":"2024-07-07T21:58:45.000Z","size":11,"stargazers_count":37,"open_issues_count":2,"forks_count":34,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-06-03T20:46:43.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parse-community.png","metadata":{"funding":{"github":"parse-community","patreon":null,"open_collective":"parse-server","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null},"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2014-11-14T19:56:13.000Z","updated_at":"2025-03-16T02:52:31.000Z","dependencies_parsed_at":"2025-05-16T18:36:53.825Z","dependency_job_id":"626fb7c5-1e74-4536-8735-61414edbc870","html_url":"https://github.com/parse-community/parse-facebook-user-session","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parse-community%2Fparse-facebook-user-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parse-community%2Fparse-facebook-user-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parse-community%2Fparse-facebook-user-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parse-community%2Fparse-facebook-user-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parse-community","download_url":"https://codeload.github.com/parse-community/parse-facebook-user-session/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parse-community%2Fparse-facebook-user-session/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258628922,"owners_count":22732292,"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":"2025-06-06T00:39:13.846Z","updated_at":"2025-06-28T15:31:36.008Z","avatar_url":"https://github.com/parse-community.png","language":"JavaScript","funding_links":["https://github.com/sponsors/parse-community","https://opencollective.com/parse-server"],"categories":[],"sub_categories":[],"readme":"parse-facebook-user-session\n===========================\n\nA Cloud Code module to facilitate logging into an express website with Facebook.\n\nIf you'd like to require users to be logged into Facebook to access pages\non your site, it's easy using the `parseFacebookUserSession`\nmiddleware module. First set up the `parseExpressCookieSession`\nas described in\n\u003ca href=\"https://parse.com/docs/hosting_guide#webapp-users\"\u003eour express docs\u003c/a\u003e.\n\n    var parseExpressHttpsRedirect = require('parse-express-https-redirect');\n    var parseExpressCookieSession = require('parse-express-cookie-session');\n    var parseFacebookUserSession = require('cloud/parse-facebook-user-session');\n\n    // ... Configure the express app ...\n\n    app.use(parseExpressHttpsRedirect());  // Require user to be on HTTPS.\n    app.use(express.bodyParser());\n    app.use(express.cookieParser('YOUR_SIGNING_SECRET'));\n    app.use(parseExpressCookieSession({ cookie: { maxAge: 3600000 } }));\n\nThen use the `parseFacebookUserSession` middleware on any page\nthat you want to require Facebook login on. Whenever the page is visited, if\nthe user has not logged into your app with Facebook, they will be redirected\nto Facebook's site to start an OAuth flow. Once they get a login token from\nFacebook, they will be redirected back to an endpoint on your site. In the\nexample below, the endpoint is `/login`. The middleware module\ntakes care of handling that endpoint for you, authenticating the user and\nredirecting them back to the original page they tried to visit. To enable this\non every page, use the `app.use` express method.\u003c/p\u003e\n\n    app.use(parseFacebookUserSession({\n      clientId: 'YOUR_FB_CLIENT_ID',\n      appSecret: 'YOUR_FB_APP_SECRET',\n      redirectUri: '/login',\n      scope: 'user_friends',\n    }));\n\nIf you'd like to only require Facebook Login on certain pages, you can include\nthe middleware in your routing commands.\n\n    var fbLogin = parseFacebookUserSession({\n      clientId: 'YOUR_FB_CLIENT_ID',\n      appSecret: 'YOUR_FB_APP_SECRET',\n      redirectUri: '/login',\n      scope: 'user_friends',\n    });\n\n    // To handle the login redirect.\n    app.get('/login', fbLogin, function(req, res) {});\n\n    app.get('/stuff', fbLogin, function(req, res) {\n      // This page requires Facebook login.\n    });\n\nYou can access the user on any page with `Parse.User.current`.\n\n    app.get('/', function(req, res) {\n      var user = Parse.User.current();\n\n      res.render('hello', {\n        message: 'Congrats, you are logged in, ' + user.get('username') + '!'\n      });\n    });\n\nYou should also provide an endpoint to let the user log out. This is as simple\nas calling `Parse.User.logOut()`.\n\n    app.get('/logout', function(req, res) {\n      Parse.User.logOut();\n      res.render('hello', { message: 'You are now logged out!' });\n    });\n\nAs a side effect of using this module, you will see objects created in your\napp's data for the `ParseFacebookTokenRequest` class. You can\nsafely ignore this class. It is used to keep track of the CSRF protection\ntokens and redirect URLs of users who are currently in the process of\nlogging in.\n\nIn order for the `ParseFacebookTokenRequest` to be created, you may need to\nenabled client class creation in your app's settings, if you've previously\ndisabled it. Once the `ParseFacebookTokenRequest` class is created, you should\ngo into the [class-level permissions](http://blog.parse.com/2014/07/07/parse-security-ii-class-hysteria/) for the class and disable all permissions. This cloud module uses\nmaster key access to access the tables.\n\n-----\n\nAs of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparse-community%2Fparse-facebook-user-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparse-community%2Fparse-facebook-user-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparse-community%2Fparse-facebook-user-session/lists"}