Repository navigation
authData:facebook vs _auth_data_facebook? #755
Description
Activity
If you see the field in MongoDB that's totally normal, the auth data gets flatten for performance reasons. Can you properly login with Facebook?
I can properly login, yes, but it's causing the other problems I mentioned, namely an invalid value for Parse.FacebookUtils.isLinked(user) and the ability to get the token from Parse Cloud. Any thoughts on those problems?
Can you provide the code you're using in cloud code?
Coffeescript:
user.get(userObjectId).then((user) -> console.log 'UserID: ' + user.id if Parse.FacebookUtils.isLinked(user) console.log 'token:' + user.get('authData').facebook.access_tokenThe second console is what would have gotten me the token before but doesn't work anymore.
Instead of Parse.FacebookUtils, do you get the right result if you query with the master key and check the authData key directly?
user.get(userObjectId, { useMasterKey: true }).then((user) -> if user.get('authData') && user.get('authData').facebook console.log user.get('authData').facebook.access_token
That does not solve it (I posted old code and was already calling useMasterKey).
Even when the user is connected to Facebook, the authData field is showing up like this:
"authData":{"facebook":null}When I check mongo directly, I see the data is being stored in the "_auth_data_facebook" field and I don't seem to have any way to access that field as it's not showing up in the returned user object.
I may be experiencing a related issue. When I log in with facebook, it creates a new user every time and that user cannot be modified; for example, if I try to update the username it reverts back to the random string provided by facebook. If I log out then back in with the same facebook account, it generates a brand new user, brand new random string.
** EDIT **
Actually, this may have been related to a beforeSave that I had in place. Still investigating, but won't hijack your thread with a separate issue if it turns out that way.@michaelbina in your code,
user.get(userObjectId)does that refers to a userQuery?Is the user currently logged in?
Can you share more of that snipet so we have more context?Yes. It's a Parse.Query(Parse.User) object. I'm not sure it should make a difference if the user is logged in since it's running from cloud code. Should I be doing something with a session token or something to get more user data or something? Here's the entire function:
Parse.Cloud.afterSave "AnimalTimelineEntry", (request, response) -> console.log("timeline entry created: " + JSON.stringify(request)) console.log("shareToFacebook: " + request.object.get("shareToFacebook")) console.log("shareToTwitter: " + request.object.get("shareToTwitter")) if(request.object.get("shareToFacebook")) console.log("sharing to Facebook for: " + request.object.get("createdBy").id) userObjectId = request.object.get("createdBy").id entryText = request.object.get("text") userQuery = new Parse.Query(Parse.User) userQuery.get(userObjectId, useMasterKey: true ).then((user) -> console.log 'User: ' + JSON.stringify(user) # if Parse.FacebookUtils.isLinked(user) # if user.get('_auth_data_facebook') # console.log 'token:' + user.get('_auth_data_facebook').access_token if user.get('authData') && user.get('authData').facebook console.log 'token: ' + user.get('authData').facebook.access_token Parse.Cloud.httpRequest( method: 'POST' url: 'https://graph.facebook.com/me/feed' params: access_token: user.get('authData').facebook.access_token message: entryText + "\n\nCheck out Phoebe on White Rabbit Apps" link: "http://www.whiterabbitapps.net/cat/phoebe_the_bug" ).then ((httpResponse) -> console.log("back from http request") ), (error) -> console.log("error with http request: " + error.data.error.message) return response.error(error.data.error.message) else return Parse.Promise.error('user not linked to fb account') return ).then ((result) -> console.log "result from post: " + JSON.stringify(result) return response.success 'Post' ), (error) -> console.log error console.error error return response.error("Error posting") returnThis should be fixed by #952
Before migrating to parse-server on heroku, all of the Facebook auth data was stored in the authData field for a User object like so:
After migrating, I am seeing the field _auth_data_facebook like so:
First, why was this changed?
Second, I am having problems accessing the _auth_data_facebook from Parse Cloud.
A search for a user in parse cloud, returns the user object without the _auth_data_facebook field and with the facebook field in authData set to nil. Also my call to Parse.FacebookUtils.isLinked(user) returns false even thought its true and I have no way to retrieve the access token from the user object.
Any help would be appreciated in figuring out what I'm doing wrong or if this is a bug. Thanks!