Parse
When the user is logged in using Parse's TwitterUtils you get this method called twitter
. Right now I'm using Swift, so with PFTwitterUtils.twitter()
you'll get all the data needed. I guess it should be [PFTwitterUtils twitter];
in Objective-C.
The class is PF_Twitter
on Parse.
Fabric TwitterKit
Once you get that object you'll get access to authToken
and authTokenSecret
for the current user.
Then you gotta use this method from TwitterKit (Note: This will be deprecated in the future, look at the UPDATE at the bottom):
Objective-C:
[Twitter sharedInstance]
logInWithExistingAuthToken:authTokenSecret:completion:
Swift:
Twitter.sharedInstance().logInWithExistingAuthToken(authToken, authTokenSecret: authTokenSecret, completion: { (session, error) -> Void in
})
If everything went well, this will return the current session.
Documentation:
Parse:
https://parse.com/docs/ios/api/Classes/PFTwitterUtils.html#//api/name/twitter
PF_Twitter - https://parse.com/docs/ios/api/Classes/PF_Twitter.html
Fabric:
https://docs.fabric.io/appledocs/Twitter/Classes/Twitter.html#//api/name/logInWithExistingAuthToken:authTokenSecret:completion:
UPDATE:
I just noticed that logInWithExistingAuthToken
will be deprecated. So the best way to do this is using the TWTRSessionStore
's saveSessionWithAuthToken
method:
Twitter.sharedInstance().sessionStore.saveSessionWithAuthToken(authToken, authTokenSecret: authTokenSecret, completion: { (session, error) -> Void in
})