Skip to content
This repository has been archived by the owner on Oct 5, 2019. It is now read-only.

Any trick to force persisting user session with TWTRSessionStore? #61

Open
tadija opened this issue May 14, 2018 · 6 comments
Open

Any trick to force persisting user session with TWTRSessionStore? #61

tadija opened this issue May 14, 2018 · 6 comments

Comments

@tadija
Copy link

tadija commented May 14, 2018

Since TwitterKit 3.2.1 (and in 3.3.0) user session is not persisted after the app is closed, so user has to repeat login procedure on each app launch. For some reason, this is not the case only if the app is opened in debug mode from Xcode.

I'm wondering if anyone found some workaround for this (within TwitterKit)?

I've tried to manually call saveSession: upon successful login, but that didn't make a difference. Also reloadSessionStore or sessionForUserID: or just delaying the call to sessionStore didn't help.

I guess it fails somewhere after unsafeLoadAllUserSessions so authSessionCache remains empty, but I don't have idea why.

@zapjonny
Copy link
Contributor

Is this true? No persisting?
Actually I am still using the previous, closed-source, version of TwitterKit. I've made my own client to replace TwitterKit, and the last thing I need to do is migrate existing tokens. So yeah it's not exactly related to this but chances are current TwitterKit session persistence is the same as in previous versions...

@tadija
Copy link
Author

tadija commented Jun 28, 2018

@zapjonny I think you should be fine with that version, this is regression in the last 2 (open source) versions.

@zapjonny
Copy link
Contributor

Yes, it was sub-par so I never started using it. And now it's being deprecated, which is really the reason why I ended up here.

Anyway I figured out how to excavate existing TwitterKit oauth sessions using the method I described above. I just looked around in the open-sourced twitterkit session saving classes to figure out how to do it. Somehow persistence looks like it SHOULD work even with the newer opensource twitterkit lib, but I'll never now... and now I'm close to fully migrating away.

@zapjonny
Copy link
Contributor

Here is what I did https://gist.github.com/jonnyijapan/8330876807be71a8237b26b5f13d70ad

@tadija
Copy link
Author

tadija commented Jul 18, 2018

I ended up implementing a temporary workaround for this issue which goes like this:

  1. After the initial login with TwitterKit, manually save retreived session's authToken and authTokenSecret somewhere secure (ie. Keychain). Also, remember to clear this data when user logs out.

  2. Later on the next app start, manually pull out this data and if it exists use it to call saveSessionWithAuthToken:authTokenSecret:completion method on TWTRTwitter.sharedInstance().sessionStore. In completion check if session is still valid (it should be) and then continue with loading user or whatever.

So until I implement a new "TwitterKit" for my app, I'm stuck with this. At least it's no longer necessary to login each time the app is opened... :)

@Radar966
Copy link

my account has been suspended

 I think the reason is a lot of Twitter, Twitter and follow-up

I would like to apologize to you

If you would give me another chance

Thank you

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

No branches or pull requests

3 participants