Twitter JS API - get current logged in user - twitter

I am using twitter #anywhere JS API in my application and don't know how to use their methods and properly execute them. At present, I am following this docs for the API.
I am working on a scenario where, I need to check from my app, if any twitter user is logged in on the same browser, get the current twitter user details and cross check with my app for the twitter user. If the user exists in my app, automatically login the user. (more importantly it should not ask the user to connect to the twitter app. Without asking the credentials I need to get the currentUser)
NOTE: Facebook already supports this type of method. We can get the facebook loggedin user session from getSession() method.
Is there anyone there to help me out on this one?

Related

iOS Instagram login every time issue

I am using instagram API in my client's app. This is a kind of a social networking app with profiles for each user. In this app, there is a section which displays instagram recent pictures of a person on their profile page. The issue is that I'm having to log the user in every time they go to view the profile in the instagram section. Can we have it so the user only has to login once and never again?
In other apps like Tinder, we login only once and then our profile is connected to instagram - even if you close the app. This means the app is either storing instagram credentials or the pictures. But latest documentation on instagram developer portal says don't store login credentials or pictures. How can I mimic this behaviour in our app?
For the login purpose, you can retrieve the access token for the particular use which you can store and for the every data retrieval request you can use that access token to get data without making user login again till the access token is valid
to get an access token you can follow the Instagram guide : Instagram: User Authentication
Which is like
Direct the user to our authorization URL. If the user is not logged
in, they will be asked to log in. The user will be asked if they
would like to grant your application access to her Instagram data.
Client Side login
For the images for another user,If you want the public feed of the user you can get directly if you already have the username of the Instagram user by making a get request without need of authentication/access token
https://www.instagram.com/{user-name of Instagram user for which you have to retrieve the media}/media/
Ex: https://www.instagram.com/instagram/media/ , this will return json with the public feed images

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.

Adding Facebook register/login to app

So I've done some research to add a register and login feature to my new app. I want to add the following things: Facebook, Twitter and my own register/login options for the users.
I've dived into some SSO from Facebook, looked into some php scripts on how they do it. So basically correct me if İ'm wrong.
User clicks on Facebook button
App checks if user is already in the database with the oath_provide en oauth_uid
If not: User is getting asked by Facebook API for accepting
App submits the oauth_provide (Facebook) and oauth_uid (user id) from the media that they've chosen to my SQL database.
User accepts and logs in to my app.
User is logged in
Same is probably for Twitter. Thanks in advance!

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

How do I associate my facebook app user with my web app user?

I have a facebook fbml app and a web application. I want my web application users to be able to add my facebook app. Seems simple, right?
Currently, I am making the connection by adding a param to the canvas page link in my site. For example, I have a link that says "add our fbook application" which links to http://apps.facebook.com/our_fbook_application?suid=786432878923
suid is the logged in user's uid on my site. Adding this to the canvas link params allows me to connect their site uid to their fbook uid on my site. This way when requests come in from facebook, I can authenticate them based on solely the fbook uid after the connection is made.
This seems like a security issue. I think an attacker could log into their facebook account and guess user id's by calling http://apps.facebook.com/our_fbook_application?suid=x and when x corresponded to a suid on my site, he would be authenticated to see that user's data.
This connecting of a facebook app user to a website user seems like it should be really common practice, but all I can find these days is facebook connect examples which I am not supporting yet.
Can someone walk me through the steps to connect a facebook app user to my website user? Major bonus points if someone can do it in Rails with the facebooker gem.
Thanks!
don't pass the suid as a variable.
Instead, on your backend, associate the FB uid with the suid.
When the user accesses the app via website, he/she will have to log in (maybe through fb connect?).
When the user accesses the app via FB, your page should be able to determine the fbuid of the user and map that to the correct suid and log the user into your site.

Resources