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.
Related
I have iOS native app , need to display stories from Facebook fan pages , currently I have to enforce users to login to Facebook throw my App to see the page posts , is there a way to let them see the posts without enforcing them to login ? specially the page is public and I can open it from any web browser without login.
I have found the solution for this issue as follow
you can use your appID|App_secret as an access token , this will enable the retrieval of any content without enforcing the users to login
but this is not safe to be used from the client side since this URL can be intercepted and app secret being revealed.
The saver implementation is to use this on server side and work as proxy between the client application and FB API.
I'm using omniauth-twitter for twitter log in to the website and it works perfectly well (go to /auth/twitter, user authenticates, and then redirect_to /auth/twitter/callback). Great.
However, on the iOS side, how can I implement sign in with twitter? Do I do it client side or server side? Could anybody go through the steps? (note: the only way to sign in to the app is through twitter)
We've tried:
using a UIWebView that goes to /auth/twitter, but on redirect, it goes back to the web version. Is there a way to get JSON data from the UIWebView?
doing sign in with twitter client side, and using a made up password to authenticate in sessions#create that matches a made up password on the db.
Is there another alternative for authentication? I know what we're doing has a lot of flaws but we couldn't find any other solutions even after asking in meetups and researching online for days. please help!
You could add an OAuth 2
implementation on your server. Your server authorizes the iOS app for an authenticated user / content owner. (You have completed the authentication part.) Once authorized, the iOS app accesses that particular user's content (via an api on your server) as if it is logged in as that user.
You will find one potential OAuth 2 provider implementation for RoR as
applicake/doorkeeper
You will find a sample iOS client application as
telegraphy-interactive/OAuthClientSetup
That is one suggestion, in any case. Not the whole answer, which would require a book chapter.
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....
I am using Twitter oauth for achieving the auto-login concept by providing the username and password. I am only able to get the data from my Twitter account. How do i login to Twitter by providing the username and password as parameters to some function which may be Twitter API login function or whatever the function. Did anyone come across this issue? If so please process me the code or links.
I want to achieve the following using oauth Twitter API or xauth... or some script:
I have an icon (Twitter) in my air application which has some background details like url (www.twiiter.com), username, password.
If i click the Twitter icon, i want the Twitter site to login automatically and to be rendered on my AIR browser (webkit).
It can be anything like Twitter API or some script which does the login mechanism.
I am stuck with this, How do i login to Twitter using auto login?
The Twitter API no longer supports authenticating to Twitter with a user name and a password. In order to use the API, you need to implement OAuth either by writing your own implementation (which I strongly advise again) or by using a library that someone else has written.
Which one you use depends largely on your development platform.
I have an application where i need to login to a website through facebook, twitter and the website's own login.
I'm not very sure how to login through facebook and connect it to the website. Like if i click on login with facebook button, it redirects to facbook login page( which is achievable with all the tutorials and information provided in the facebook developer documentation and the sdk) and then it is redirected to the website immediately after facebook login.
How to achieve this? Any suggestions or help to achieve this will well appreciated.
I also would want to know about the encrypted access token of facebook. How to use that access token. I have read the documentation, yet i have not got the concept so clear in my head.
EDIT: the website is already connected to facebook and twitter... I have to to the same on iphone.. I mean, the response i will get after login through facebook is an access token. Can i use this access token. How to link the response got after facebook login to the website to authenticate a user's login. This i need to do it in iphone.
Thanks in advance.
Here is an example on how to do it with php,
Facebook as Auth
EDIT:
As you mention you already have a website in place with facebook and twitter integration and only require to do it in iPhone.
For iPhone have a look at facebook sdk for iPhone.
What you get after a authentication from facebook in iPhone app will be a access_token. You can use this token to get the facebook userid. Match the same id with the one present in the website. This way you can validate a user.
For getting user details from acess_token try this.
graph.facebook.com/me?access_token=<token>.
This will return basic user information along with facebook userid.
Best of luck.