Skip to content
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

My PFUser.current()?.sessionToken is nil #1038

Closed
kevinlee85 opened this issue Sep 21, 2016 · 17 comments
Closed

My PFUser.current()?.sessionToken is nil #1038

kevinlee85 opened this issue Sep 21, 2016 · 17 comments

Comments

@kevinlee85
Copy link

I did one login by PFUser, then rebuild my project to launch my app again, then the PFUser.current() is not nil, but the sessionToken is nil, therefore I cannot save object to PFUser.current() object.

Any suggestion?

Thank you in advanced!

@Viktormax
Copy link

I've the same issue, need to re-login every time. What a mess!!!!

@mikall
Copy link

mikall commented Sep 22, 2016

Hi men, same here.
After we re built the project with xCode 8 and swift 3 at every run the current User session Token property is nil and is not stored, whereas any other property still works out.
Any ideas?

Same behaviour on parse.com and parse-server (v 2.2.17)

Thank's
Michele

@Viktormax
Copy link

We found the solution!
Apple changed the way of working with keychain in iOS 10. To fix this issue you simply should go to Targets->Capabilities and enable keychain sharing (it enables access to keychain for your app):

from: http://stackoverflow.com/questions/38689631/how-to-use-facebook-ios-sdk-on-ios-10/38799196#38799196

@jackdewhurst
Copy link

Just spent 2 hours trying to work out why users don't work on iOS 10 / Xcode 8...
On second launch of the app every call to fetchIfNeeded on _User returned a 404 with the Parse Server logging 101 - "Object not found".

This is the solution!

Thank you so much Viktormax!

@enel-lightning
Copy link

I have the issue. Any suggestion?

@lexin
Copy link

lexin commented Nov 24, 2016

"enable keychain sharing" helps me! thank you!

@ryanwaggoner
Copy link

If anyone runs into this, I turned on keychain sharing and still had the issue. I had to clean, delete the app, and reinstall to get things to work properly.

@stale
Copy link

stale bot commented Sep 19, 2018

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

@stale stale bot added the wontfix label Sep 19, 2018
@stale stale bot closed this as completed Sep 26, 2018
@christianpbrink
Copy link

Never had this before, but it's suddenly happening constantly, only one one device (my dev device). Happens on old releases of our app and new, after full uninstall+reinstall+device restart, full Xcode build cleaning+build folder cleaning+derived data removal+ everything else you can think of, everything mentioned above on this thread — keeps happening.

Just started today.

Really sucks. Any ideas? Thanks in advance!

@christianpbrink
Copy link

christianpbrink commented Mar 22, 2019

A bit of context, as I've just read some of parse-community/parse-server#4897

Earlier today I updated my Parse iOS SDK from 1.15.3 to 1.17.2. This updated code was only ever run on my dev device, the one that the issue is now happening on. I subsequently went back to an old build running 1.15.3, and have since gone back and forth among a bunch of different builds from recent weeks, only the very newest of which run anything but 1.15.3. In the course of doing this I have repeatedly fully uninstalled the app, restarted my phone, cleaned the crap out of Xcode, etc. I've also deleted all the users I signed up or logged in as while running SDK 1.17.2 from my parse-server mongo database (have done this repeatedly).

Can it possibly be the case that simply having run this code once on my device somehow corrupted it for good in this specific way? How?? I feel like that can't possibly be it. But.. what else explains it?

Something that seems to clinch the theory, though without explaining anything: When I go back to running the newest builds, the one that run 1.17.2, the problem goes away.

@christianpbrink
Copy link

Tried a slightly adapted version of the cloud job shown here — no luck.

@christianpbrink
Copy link

A bit more context. PFKeychainStore logs this error message when an attempt is made to save the session token following a login:

PFKeychainStore failed to set object for key 'currentUser', with error: -25299

Which leads me here.

Now going to be investigating how a duplicate keychain has gotten left on the device despite a full uninstall+reinstall.

@christianpbrink
Copy link

christianpbrink commented Mar 22, 2019

What @tekmick said over here reminded me about the policies of this open source project in general... I have a hunch y'all are gonna say we just need to permanently update to the latest SDK version. Will probably plan to do that.

@christianpbrink
Copy link

Got a solution. Used the FDKeychain library and added the following code right after my call to PFUser.logOut():

                    do {
                        try FDKeychain.deleteItem(forKey: "currentUser", forService: "<bundle_id>.com.parse.sdk")
                        print("deleted currentUser from keychain!")
                    } catch {
                        print("tried to delete currentUser from keychain; wasn't there!")
                    }

Fixes it again each time it's been broken.

@claesjacobsson
Copy link

claesjacobsson commented Jun 30, 2019

As I understand it, this was fixed in 1.17.2?

And did this problem only occur on your development device? As you understand it, will it only happen when going back and forth between SDK versions? No production users affected?

I had this issue on my main dev device. When testing with another device it didn't have any problem at first, but after going back to the older Parse SDK version it started happening on the other device too.

My main concern: how likely is this to happen in production?

@christianpbrink
Copy link

Sorry Claes; I haven't thought about this since we came up with that workaround in March.

@claesjacobsson
Copy link

Ok, thanks for letting me know :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants