parse-facebook-user-session icon indicating copy to clipboard operation
parse-facebook-user-session copied to clipboard

Result: TypeError: Cannot call method 'restoreAuthentication' of undefined

Open dmonizer opened this issue 10 years ago • 0 comments

Here's my app.js: ---------------------------| app.js |------------------------------------------

// These two lines are required to initialize Express in Cloud Code. express = require('express'); app = express();

var parseExpressHttpsRedirect = require('parse-express-https-redirect'); var parseExpressCookieSession = require('parse-express-cookie-session'); var parseFacebookUserSession = require('cloud/parse-facebook-user-session');

// Global app configuration section app.set('views', 'cloud/views'); // Specify the folder to find templates app.set('view engine', 'ejs'); // Set the template engine app.use(express.bodyParser()); // Middleware for reading request body

// FB stuff app.use(parseExpressHttpsRedirect()); // Require user to be on HTTPS. app.use(express.bodyParser()); app.use(express.cookieParser('fdft453242f')); app.use(parseExpressCookieSession({ cookie: { maxAge: 3600000 } })); // /FB stuff

var fbLogin = parseFacebookUserSession({ clientId: 'my client id', appSecret: 'MY_APP_SECRET', redirectUri: '/secret', scope: 'user_friends', });

// This is an example of hooking up a request handler with a specific request // path and HTTP verb using the Express routing API. app.get('/', function(req, res) { res.render('main', { message: 'Congrats, you just set up your app!' }); });

// To handle the login redirect. app.get('/login', fbLogin, function(req, res) {});

app.get('/secret', fbLogin, function(req, res) { // This page requires Facebook login. res.render('secret', { message: 'Congrats, you are logged in!!' }); });

// Attach the Express app to Cloud Code. app.listen(); ---------------------------| /app.js |------------------------------------------

When going to /secret, i get forwarded to facebook login page, if I login, I get diverted back to /secret with ?code=XXXXXXX at the end of address but error in log:

E2015-09-16T09:03:10.606Z]v14 Ran custom endpoint with: Input: {"method":"GET","url":"/secret?code=XXXXXXXXX","headers":{"accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image /webp,/;q=0.8","accept-encoding":"gzip, deflate, sdch","accept-language":"en-US,en;q=0.8,et;q=0.6","cache-control":" ma... (truncated) Result: TypeError: Cannot call method 'restoreAuthentication' of undefined at t.s.value (Parse.js:13:14231) at t.s.value (Parse.js:13:14403) at Object.T.setCurrentUser (Parse.js:13:18637) at e. (Parse.js:13:21603) at e.s (Parse.js:12:26759) at e.n.value (Parse.js:12:26178) at e. (Parse.js:12:26831) at e.s (Parse.js:12:26759) at Parse.js:12:27145 at i (Parse.js:12:27100)

Am i doing something wrong?

dmonizer avatar Sep 16 '15 09:09 dmonizer