parse-community / parse-facebook-user-session Goto Github PK
View Code? Open in Web Editor NEWA Cloud Code module to facilitate logging into an express website with Facebook.
License: Other
A Cloud Code module to facilitate logging into an express website with Facebook.
License: Other
I followed exactly exmeplo but to shoot the user.get('name') return only undefined
The following code
Parse.initialize("key...","key...");
var currentUser = Parse.User.current();
When run after logging in a user using "parse-facebook-user-session.js", sets the currentUser as "null"
Is there a way for the cloud code to communicate the current facebook user session to the javascript SDK?
I'm trying out this middleware but I'm always getting error code 101 - invalid session originating from line: https://github.com/ParsePlatform/parse-facebook-user-session/blob/master/parse-facebook-user-session.js#L136
The rest of the verbose output looks fine
I2015-06-07T21:23:34.402Z]Redirecting for Facebook OAuth.
I2015-06-07T21:23:35.106Z]Handling request callback for Facebook login...
I2015-06-07T21:23:35.310Z]Fetching user data from Facebook...
I2015-06-07T21:23:35.462Z]Logging into Parse with Facebook token...
I2015-06-07T21:23:36.024Z]Failed! {"code":101,"message":"invalid session"}
I'm using the "new" revocable sessions and am considering if this could be related?
When using the sample parse-facebook-user-session code and using req.user.get('username'); to get the current user username, the Parse Express / NodeJS hosting server returns an internal Server Error
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?
When using the following code sample:
app.get('/', function(req, res) {
var user = Parse.User.current();
res.render('hello', {
message: 'Congrats, you are logged in, ' + user.get('name') + '!'
});
});
The user.get('name') function returns "undefined"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.