-
-
Notifications
You must be signed in to change notification settings - Fork 878
Error 206 cannot modify user for new Facebook user #1492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ok. I think you're making this a little more complicated than it is. Seems to me the cloud login is unnecessary. You have two choices with how to do this automatically right within the parse on iOS. First, if you include ParseFacebookUtils aka a) Do it manually with the access tokens
b) Have parse do the facebook login with the user automatically. This will automatically bring up the window. Have them authorize. Create a user that will become currentUser. You can still do user.isNew() to do further registration if you'd like.
If this isnt easy enough and you want to insist on using cloud code. Youll need to login on the cloud, have the cloud function pass back the session token. Then do something like this.
I honestly would ditch the cloud code on this one. I use cloud functions a ton but this is just built in so nice and neat that all we can really do is add more complexity and make it easier to break. Stick to the native functions and you'll be amazed how super simple it is. Also, if you do use carthage or cocoapods it automatically loads the facebook SDK. To set it up to work with parse automatically simply follow this . Then on your login page just do the
Automatically sets current user. Adds token to the new user the first time they log in. Also, you can use parse's library to link and unlink facebook. One thing I'd like to point out is that Apple now requires you to offer Apple Sign In, if you allow any other 3rd party oAuth. As in, they will reject your app if you dont add it too. We are currently working on adding it to ParseUI and also have its own module. So, that should be coming shortly. |
No, I am not using cloud code. I am using Facebook iOS sdk method and it was working fine. @dplewis had asked me to try out cloud code so that’s just test code. I have done some digging. Pls check issue parse-community/parse-server#6511 And I have coded Sign In with Apple also and that too is failing because this same reason. |
Ok @ashish-naik ok I get the basic idea. First like me ask two things. 1) is there already an anonymous or previous user prior to this? 2) the returned/current user is not null. It just wont let you make any changes to it. You get that error instead right? Just making sure I understand. |
|
Ok so quick question not sure if you use dashboard. Kinda makes these things easier but if not no big deal. So, in the cloud code. We do sessionToken on console.log("NEW User logged in with id " + user.id + " with session token : " + user.sessionToken)? |
Also, this occurs weather this process creates a new Parse user or not correct? |
I find this a bit weird
Primarily the "returning as no auth provider" |
Yes new user is created. I didn’t understand previous question abt console.log |
Heres your cloud code for logging in using facebook. I'm wondering if session token prints here. Parse.FacebookUtils.logIn(facebookAuthData, { useMasterKey: true }) |
No it doesnt print. and you want me to use JSON.stringify(user); in console.log in cloud code? Havent used it before. |
Yea user is just a Javascript Object which should break down and show you everything associated with that user. So, really quick. The end goal here is to create a new user with the facebook auth data. Right? |
I got this
|
So heres whats happening. I think there is no sessionToken necessarily being created because theres no device to link the session to. Its either it figures accessToken already has a expiration date which is as good as a session token anyway. or they arent creating it because this is done in Cloud code can be called by about anything. Also, cloud code isnt going to automatically respond with the user information either way. So I have an Idea that I think might sort this all out doing it natively that not only will create the session token but also Either way. I think I got your solution. Combines what you did in cloud but does it natively so that currentUser can be set automatically.
Try signing up this way and see what happens. |
If that doesnt work the way it should try this.
|
My bet one of the two will work once the save or signup is completed. Also, good news. You shouldnt need to use master key doing this natively. |
linkWith resulted in error
|
Yea try this one. user.signUpInBackground { (completed, error) in |
i got error that username needs to be set so did and then got error |
it is well past midnight for me in India so I will have to pause now. Let me know what else to try. Will pickup tomorrow. |
Once this next release is out I'm going to impliment a way to make this simple. Try this when you get a chance.
|
If this doesnt work Ill have to dig through the FacebookUtils to see what they do with the data to make it work. I think this should work though. |
Didnt work. this Below is heroku log before return this.getUserAndRoleACL() Before you dig into FacebookUtils, i want to highlight that same issue is happening for Apple with in also so doubt this is FacebookUtils related. I am wondering why findUsersWithAuthData returns no data. is it trying to find just created _User object via POST? if so then i have a feeling that findUsersWithAuthData is called before creation. I may be naive because this is most basic core functionality but i am also intrigued. Noticed one more thing, with your above code, validateAuthData is called once and not twice if you check log in my other post 6411. |
God bless Heroku logs. I found your problem. Should have thought of this before.
So, your configuration on the server is that you require not only an email on the account to login, but verification of that email. Neither of which you are doing in your cloud code or natively when you pass the objectId back. So the user is saving. You can query that user with that auth data. However it wont log in until those restrictions are met. Just till you get this working and add a registration page to add their email, turn them both off. After that lets try it again and let me know if there is any difference. Btw..with the way we setup that task it automatically passes the user back as the argument in the closure once the task is complete.
Although, the email settings are issues, I'd like to reiterate this is so much easier using "Parse/FacebookUtils" native submodule for the iOS sdk. Its basically a helper built around the Facebook SDK. Everything you want to do authenticate with facebook, automatically create a new user with session token using authentication data(and email if you want) with email verification, can be done in about 10-20 lines of code. In fact Facebook literally helped with making the native FacebookUtils submodule for Parse during the time they owned Parse Platform. It streamlines everything and makes it all really simple. Even linking. Using Parse/FacebookUtils for iOS, you can allow linking facebook later literally 3 lines of code. Lets say a user is already registered with password/email or username. Add a button for linking facebook and it all happens automatically just running.
Facebook sign in window or app opens, allowing the user to authenticate and accept any permissions requested, its returns to the app passes back the auth data, adds it to the current user, and saves it all in 3-6 lines of code. It would take quadruple the amount of code just using the facebook SDK and adding it to the user manually. Anyway, something to think about. Even graph requests are easier. Anyway, temporarily change those configuration settings, make sure this works, then turn them back on when you implement a way to have the user input and verify their email during this process. Hit me back if you have any questions and let me know how it goes! |
So i commented verifyUserEmails and tried sign up for both Facebook and Apple and it worked.
i am using Parse/FacebookUtils for iOS which is super simple as you mentioned and use With verifyUserEmails removed, i am able to sign up successfully using Facebook and Apple and not getting error 206 also because session token is generated. See log below.
I have three ways of sign up: Facebook, Apple and Email/Password. I have tested that email verification works when user signs up using email when verifyUserEmails is enabled hence i didnt understand your below comment.
|
And I didn’t use cloud code for testing after removing f verifyEmail option. I have used my original code that use Parse/facebookUtils. |
Perfect! Glad ya got that going. I think you are correct that email verification is for email based signup only. Cant remember specifically testing that but I've been using Parse for so long with email verification and 3rd party oAuth that I imagine I'd know if that wasnt the case. Now that we just got 1.18.0 out we're probably going to be working on getting Apple Sign In integrated into Parse for our next release. Just something to watch for. |
Hi Nathan, congratulations on new release and thanks for helping with figuring out the issue. However, I want to use email verification for users signing up using without auth. How to go about that? I found a post that was left unsolved i guess. Not exactly for this issue but related so just mentioning here because i may need this as well. or was this addressed? I have tried to explain the probable and cause and fix below. When
But in this flow,
So i tried this fix
from inside
to just before it. After this change sign up with facebook and login both worked, sign up and login with email also worked. I have not added function for linkWith in my app so cannot test it yet. is this is a valid solution? |
@noobs2ninjas Appreciate if you could check my above comments. |
@dplewis For error 206 i have been facing, i changed the code as above and my error went away. is this a correct fix? Could you please take a look? |
This issue has been automatically marked as stale because it has not had recent activity. If you believe it should stay open, please let us know! As always, we encourage contributions, check out the Contributing Guide |
@ashish-naik Did you manage to find a solution for this ? |
Check parse-community/parse-server#6511 I am waiting for someone from Parse team to check the solution Working for me. |
@ashish-naik Thanks for the quick response. Strangely to me, turning off the "Prevent login if email is not verified" feature made the Social sign in work. I'm planning to implement a "beforeSave Trigger" for a user signing with auth data and update the "emailVerified" to true as a temporary fix until we get a proper fix from the sdk. |
Don't think you can update that but give it a try. |
@dplewis As you suggested i have created issue here.
I am getting error 206 after new Facebook user is saved and reason seems to be nil sessionToken.
I am facing this for Apple sign in also randomly. This is probably getting fixed by #6416. Don't know whether Facebook issue will also be fixed.
I have one old account created on Heroku Parse server which works fine ie i am able to save attributes after login.
I was running server v3.9.0. tried upgrading till 4.0.2 but still failing.
I am updating PFUser object post login locally in iOS client using Swift. Not using cloud code for this.
Also failing on back4app v3.9.0. Sign in with Apple also failing on back4app but works randomly.
Works on local setup consistently. Local server installed using bootstrap.sh script.
I have seen some issued dated 2016 fixing this error but server code seems to have changed lot so cannot view the same code referred in #952
using FBSDKCoreKit 5.15.1, FBSDKLoginKit 5.15.1
Steps to reproduce
on iOS, Try login using a facebook account that is not yet created on Parse.
Running iOS 13.3.1
Expected Results
After successful login, should be able to save other attributes in PFUser.current() object
Actual Outcome
The login is successful but saving any attributes fails with error 206 "cannot modify user xxxxx"
Fails on back4app also. v3.9.0
Both Apple and Facebook new user registration and update work fine in local environment.
Environment Setup
Server
parse-server version (Be specific! Don't say 'latest'.) : 3.9.0 to 4.0.2 (Local 3.10.0)
Operating System: heroku-18 (Local MacOS 10.15.3)
Hardware: heroku-18 (Local MacOS 10.15.3)
Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Both as mentioned above
Database
MongoDB version: mLab 3.6.12 (Local 4.2.3)
Storage engine: mLab
Hardware: mLab
Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): both
Logs/Trace
Mar 15 02:51:40 yovl app/web.1 error: Parse error: Cannot modify user kc30Xbk1wA. {"code":206,"stack":"Error: Cannot modify user kc30Xbk1wA.\n at RestWrite.runDatabaseOperation (/app/node_modules/parse-server/lib/RestWrite.js:1170:11)\n at /app/node_modules/parse-server/lib/RestWrite.js:127:17\n at processTicksAndRejections (internal/process/task_queues.js:97:5)"}
package.json used for deployment to Heroku
I tried below. Not good with cloud code so hope code is not wrong.
Cloud function
ios Code
Server log
if i run code for a registered user without master key, i get sessionToken printed in logs.
But i am getting undefined for sessionToken for user.sessionToken or user.getsessionToken.
Not sure to fetch access token.
Moreover, in Xcode i get PFUser.current as nil.
By the way, i had created similar issue for Sign in With Apple also. #1477
The text was updated successfully, but these errors were encountered: