Login to Facebook comments using embedded UIWebView through Facebook SSO - ios

Is there any method to login facebook comments embbedded in UIWebView using SSO?
In my case ,I am developing website and native ios app.
so I should embbed page like below link in my native app.
http://techcrunch.com/2012/09/19/facebook-contact-sync/
this page is using facebook comments.
If I ask users one more login, this problem can be solved.
But I want to login through facebook SSO.(Don't want to ask one more user's id and password)
Facebook-ios-sdk with embedded UIWebView
this link showing me how to login my comments box in UIWebView using ios SDK...
is Answer at this link possible?
Get Access token using iOS facebook SDK,
and passing this token to java script at page to authentication user at comments box.
If it is possible, How to pass access token that acquired from ios SDK to java script SDK ?
or Does there exist another method?
I think easiest way to implement this is make session cookies for webview using access token.
but people saying this is impossible.
Loading iPhone webviews as an Facebook SSO authenticated user?
is it still impossible at new version of SDK?
Thanks in advance!

Related

OAuth Using UIWebView iOS

I would want to know how can I make user login OAuth via a UIWebView instead of Safari browser.
I've implemented Twitter OAuth with Deployd as backend, after making login with Twitter it redirects to my API url for a POST request and get stuck. It's not redirecting back to the application.
So any approach or suggestion would be greatly appreciated.
Any reason why you're not using the Fabric SDK? It makes it really easy to login a user via Twitter and it checks automatically if an account is set up in the System Settings. If there isn't one, it'll present the OAuth login option. In this way your user doesn't have to leave your app which is great.

Is it possible to call native ios Facebook login dialog from just a web page (not a web app)?

We have an ios app that uses native Facebook login just fine.
Then we also have a website (app is basically an optimized client for it) where people can login via Facebook too. When they open our website in mobile safari, they are directed to Facebook pages to authenticate there and it works, but.. it is still far from native and users have to retype credentials they often have in ios already.
So could it be possible to to somehow launch system fb authentication for just a web page (maybe using some clever URL schema?) and get granted token back to web?
Difficult way
As described here http://aaronparecki.com/articles/2012/07/29/1/oauth2-simplified#mobile-apps you could find URL scheme to trigger the native iOS app for app authorization:
fbauth://authorize?redirect_uri=[redirect_uri]&client_id=[client_id]&response_type=token
But if you call that link it's not possible to have a redirection. You could try to hack that redirection but maybe you could not find a way out.
A secure way to solve that problem is to use a SSO token to authenticate user on your App when he logs in, and next on Safari take a redirection, with a custom url to your APP, that do as bridge to FB App via Token stored in your APP. After FB authentication you can directly redirect user back to your landing page in Safari. As said by #Lego it's an alternative way to direct authenticate that could be made by going deep to custom URL used by FB.
No, it is not yet possible to directly authenticate the user via the native Facebook App, but it's possible to authenticate the user using a custom URL scheme which opens your native iOS app which then handles the authentication flow:
The user authenticates natively with your iOS App. You then store the user login (not password) in your app (i.e. using NSUserDefaults).
Then the user opens your web page in Mobile Safari. You redirect the user via a custom url scheme to your app (i.e. using myapp://authenticate). Apple documentation on implementing custom URL schemes: click
Now, if you have an active FB session in your iOS app, you can either directly redirect the user back to your landing page in Mobile Safari, passing the access token via url get parameter or you first re-authenticate the user, displaying a login view with the user name pre-filled, which you have stored in your iOS app before (step 1) and then redirect the user to your landing page, again all depending on session state and your security needs.
For opening face book app you can use Custom URL scheme. But i am not sure if u can authenticate user from it. In case if you could also then it will be confined up to the fb account which is already configured on that device app .so better try to use face book api or something
I don't get your question exactly but i think as per your question you want to create fb app Login in safari or in your custom web view.
is this perfect ?
as per my knowledge web view is different thing and native app is different thing.
if you are Login in web view then no need to check anything token or other thing because it will give you Logout thing there.
but if you are Login in your application then "developer.facebook.com" will definitely help you.
and yes, you will do most of the thing in your app as native facebook app do.
Hope it help....

Share using Facebook Application

Right now I'm using a Facebook SDK to share posts from my application. The problem is that this sdk pops up a webview inside my app and asks the user to log in. There has to be a better way.
Can I send the share information to the facebook app on the users device (If they have it installed)? Or at least leverage the facebook app to check credentials? If people have to sign in to share, they probably won't do it..
The latest Facebook SDK 3.5 includes a native share dialog. If you follow the authentication workflow according do the documentation and the phone is on iOS 6.0 you should not get a UIWebView during authentication, instead you will get a UIAlertView.
Facebook login process would use WebView only in a few cases. Some of them are:
1) You are asking it to do so explicitly, by using - (void)openWithBehavior:(FBSessionLoginBehavior)behavior completionHandler:(FBSessionStateHandler)handler; which, I think, is not your case.
2) If there is no Facebook app installed on the device, FB SDK falls back to using WebView login window.
3) Probably, this is your case. If you are requesting publish permissions on the first attempt to open FB session, FB SDK will also fall back to old login flow envolving WebView. In the new login flow, FB session is supposed to be open with read permissions first (in that case, FB will use fast app switching or native iOS FB login):
+ (BOOL)openActiveSessionWithReadPermissions:(NSArray*)readPermissions allowLoginUI:(BOOL)allowLoginUI completionHandler:(FBSessionStateHandler)handler;
Then, you should ask additional publish permissions from the user:
- (void)requestNewPublishPermissions:(NSArray*)writePermissions defaultAudience:(FBSessionDefaultAudience)defaultAudience completionHandler:(FBSessionRequestPermissionResultHandler)handler;
That way, user will not need to log in (if he is logged in FB app already), but there will be inconvenience of double switching from your app to FB (though it works rather fast lately).
I was looking for a cleaner way to get publish permissions with FB Single Sign On on the first call, but unfortunately didn't find anything working yet.

what are the differences of various FB login methods?

There are three different login methods in iOS:
Login via web pop-up
Login via Safari
Login via Native App
and one more in iOS 6 - login via native pop-up controller using iOS 6 Facebook credentials.
In my case, I'm using FB comments plugin inside UIWebView and I'd like to allow user to leave comments there. For that I'm using FB login via web pop-up. Using other methods lead to the two different results:
FB comments plugin not loading at all
FB comments plugin loaded, but user is still unauthorized (login via Safari)
Whereas I have no idea, how to deal with the first one, the second one happens I think because cookies (or FB credentials) are stored in safari, but not in my App, which is required for comments plugin to understand that the user has logged in.
In this case, I'm wondering - when and where should we use each of the FB login approaches?
And what should I use in my case?
I recommend using Parse to handle social account management. It's super easy to integrate with your code and free for your purposes. Take a look. Just sign up to Parse, Create an App and follow the easy quickstart guide. They also have great documentation and forums to help you out.

keep Facebook authentication when accessing webpage thru UIWebView after login with iOS SDK

I have successfully integrated the facebook ios SDK in my app so that user can post to their wall through a feed dialog.
However, I would like to post an open graph object through my app but since this is currently only supported on webpages (is this correct?), I suppose I can load the webpage with the meta tags inside a UIWebView. If I do so, however, I believe user have to authenticate my web app as well?
Is there a way to not need the user to authenticate my web app inside the UIWebView when they have already login through the iOS SDK? I would like to keep the iOS SDK login process because it doesn't require user to enter their facebook details (assuming they have the facebook app installed of coz)
thanks much in advance!
it looks like i am able to post feeds in UIWebView after logging in with the iOS SDK. I did logout of facebook on my safari app just in case....

Resources