Twitter / Fabric login button only working once - ios

I'm using, with success the Fabric Login button (TWTRLogInButton, https://dev.twitter.com/twitter-kit/ios-reference/twtrloginbutton).
In my Swift app I can authenticate myself, make calls and all. The only problem is that i've implemented a "Logout" button that calls Twitter.logOut().
As specified by the documentation (https://dev.twitter.com/twitter-kit/ios-reference/twitter) this deletes the local session but does not invalidate the remote session. The effect is that once I'm authenticated and then logged out, if I click the "Login" button again I'm logged-in again with the same user, effectively preventing me from switching user.
Any help?

The logOut is a class method, did you call:
Twitter.sharedInstance().logOut()

The incomplete logout issue you guys are facing is actually more related to iOS persisting system accounts. TwitterKit automatically logs a user in if they were already logged in on iOS. You can workaround this behavioral in the use case of kiosk with these steps:
Login to Twitter in Settings > Twitter
Switch to your app and attempt to login with Twitter
Disallow access to Twitter accounts when the grant access dialog comes up:
This prevents TwitterKit from accessing your system accounts and every user will have to login. Hope this helps!
(Initially Twitter.sharedInstance().logOut() destroys local session...)

use method
[[Twitter sharedInstance] logInWithMethods:TWTRLoginMethodWebBasedForceLogin completion:{}]
Parameter TWTRLoginMethodWebBasedForceLogin
Presents a web view that doesn't use any cached sessions
from Safari. Allows the developer to provide multi-user
functionality with several Twitter accounts.

I came across this problem as well, but it seems that this is how it behaves, Twitter "saves" the credentials on an OS level using Accounts
framework. You can see this here:
go to Settings on your phone -> Twitter and you'll see the account there go into the account and "Delete Account"
once you delete the account you will find that when you launch your app and try to login to twitter now you will be asked to sign in.
Once an account is added there is no way to take out the account, (unless Twitter supports this and makes it public) The User will have to manually go into Settings -> Twitter and delete the account from there to be able to sign in to a different account.
Also i noticed that when you add another account into Twitter, trying to login you will be given a chance to login either account when using
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error)
edit: Upon further Research if the User allows the app to use "Twitter" accounts you are able to access the Accounts Framework and delete the account from there:
https://developer.apple.com/library/mac/documentation/Accounts/Reference/ACAccountStoreClassRef/index.html
Cheers!

Related

How to know user has already done Facebook login at iOS app

I am developing iOS App which use Facebook iOS SDK 4.
When user has already done Facebook login, by doing Facebook login the dialog which shows "user has already approved your app" had be displayed.
So, do not show the dialog. I want to know whether the user has already done Facebook login.
Anyone know the good way? I think accessToken is returned if user once had done Facebook login.
FBSDKAccessToken manage current logged user's accessToken.
According to official Facebook Login guide
"FBSDKAccessToken Represents the access token provided by a successful login. Most important, it provides a global +currentAccessToken to represent the currently logged in user."
The currentAccessToken is a convenient representation of the token of the current user and is used by other SDK components (like FBSDKLoginManager).
According to above you can check either user has valid accessToken or not and based on this you can track call login method otherwise just skip to next flow.
In Facebook the access tokens are per user so you can pass them around apps and they will work. In your case if you can ship an access token from another app you will be able to skip the next logging in and use the API normally.
However I think this this thread will help you.
Things are a little bit different with iOS cause I have done a facebook login on Android and got no such issues.

Twitter iOS User Login

I've implemented Twitter Login in my iOS app with the following tutorial:
https://dev.twitter.com/twitter-kit/ios/twitter-login
But after I chose a Twitter account when I log in the first time, the app always defaults to this account. I would like to enable users with multiple accounts to select the Twitter account they'd like to log into each time.
How can I re-enable the UIActionSheet that allows the user to select which Twitter account they want to use for login?
There is a method Twitter.sharedInstance.logOut to delete the local Twitter user session. And you also should clear Twitter-related cookies in NSHTTPCookieStorage to prevent using of old credentials in further UIWebView-based login sequence.
The new Twitter Kit 3.0 now supports this flow by default. Every time that login is called, the user will be able to add or change their Twitter account.

facebook iphone - how login under different user

I'm making a game for iphone, so my question:
How is the end user supposed to change his login. Meaning if he decides to log in under a different name?
I noticed that even a resetting of the phone and reinstalling the app doesn't work, I'm still logged in under the same user as before.
My next guess was FB.Logout, but this page tells me not to use it:
https://developers.facebook.com/docs/unity/reference/current/FB.Logout
And also, under Settings -> Facebook I logged into another user already, too - in my game it's still using the old user...
You need to set
[FBSession.activeSession closeAndClearTokenInformation];
for Facebook Logout.
closeAndClearTokenInformation closes the session and clears any cached info, destroying the session. This means that when the app is re-launched the cached token will not be available. The login view will then be shown.
That is because that LogOut function will log out the user from FACEBOOK, not just from your app. Plus the documentation you are looking at is for unity. You should follow this guide: https://developers.facebook.com/docs/facebook-login/ios/v2.0
They show how you can easily log in and log out which is what you are looking for. If you don't have a predefined account set on the device then you will be able to log in with your email and password using the facebook log in interface (in were you can log in as a different user if you want)

Facebook iOS SDK and Safari based authentication issue

I have used latest FB SKD in my iOS app so users can use facebook account to login. Application open the FB app and comes back to my app perfectly fine. However, in some place in the app, i have to show/pull some people facebook page (safari based using WebView), but even user already used the Facebook account to login into my native ios app, but the page still ask user to login again and when they click login, it shows them the annoying FB username/pass page.
Is there anyway, that the FB safari based page can authenticate the user since it's already logged into my app using FB integration? do i have to include query or something. Please give me details how to solve this problem since i'm new in this..
thanks again for your help...
pic: https://www.dropbox.com/s/rjlptu7ufpcq3vl/fb.png
When the user switches to Facebook app to authenticate, it doesn't create a cookie for your UIWebView which is why it's asking to login again. Have the user authenticate inside the UIWebView without switching to the Facebook app.
What you're talking about also sounds like a similar thing that happens with Facebook dialogs not knowing about the current Facebook session.
If you authenticate your user via Facebook, try saying the Facebook object itself as an instance variable somewhere in memory so you can access it again (a property on a singleton controller, perhaps?).
Spawning dialogs from an authenticated Facebook object appears to let them use the dialog without reauthenticating iff you have a [FBSession activeSession]. So you'd also have to maintain an active FB session. But I'm not sure if this kind of solution will work since you didn't show specific code for how you're doing your web-based FB fetches.
This question might also prove helpful:
Implement Login with Facebook in iOS 5 and 6

Using Twitter api logout on Twitter?

User login my application with oauth, after logout my application but twitter can't do, problem is user twitter account is active.
when that logout my application at the same time logout twitter
twitter api not support this action?
No, the twitter API will not log your users out of twitter.
account/end_session only ends the current API Session. I'm working on an site that requires users to be able to log out and then log back in again with another twitter account. To do that, you have to store multiple access tokens per user and establish one as the current access token. More info in the link below.
http://groups.google.com/group/twitter-development-talk/browse_thread/thread/02e44b27d7ba3661?pli=1
As far as signing out of twitter, it's up to the user to sign into twitter and sign out themselves, which is not ideal if working on a shared computer.
Twitter just closing the session at api ,not close the session on Twitter :)
You'll have to call account/end_session to end the session of the authenticated user on twitter.
Old thread agreed, I just integrated Twitter login in my android app using Fabric. I found the following method
com.twitter.sdk.android.Twitter.logOut
I guess they have implemented it now! I couldn't find any documentation, honestly I've not put too much time into it. But I think logout means what I think it means :)
Twitter does not have api for logout. You can use the session closing api to end the user session.
You can use oauth/authenticate or oauth/authorize and add "force_login=true" parameter. This will prompt the user with a login form.
view this thread

Resources