Can I use Facebook auth server side flow on an iPhone app and still have client side interactions?

ぃ、小莉子 提交于 2019-12-04 11:10:41

I am in a similar situation. I've got an iOS native app that needs to know who the user is.

I've got a website (RoR), using Devise, that I can login to/create an account with Facebook/Twitter via it's OmniAuth gem.

However, with both Facebook and Twitter, it seems that I have to create two entries in each, one for the website, one for the app.

Those are separate API keys for each.

For the iOS app, the only way I've come up with to make this work is: * If the user wants to auth/create account via Twitter of Facebook, then send them via a UIWebView to the website to login.

Any tweets/FB posts from the iOS would actually be posted to each via an API on the website that would use the user's access token to post the tweet on their behalf.

The thing is, I rather dislike Webviews for logins. If anyone has any suggestions I'm all ears.

"I cannot use client side authentication and pass the access token to my server for authentication against my system and also to be stored for further use. The access token received for client side authentication is totally different from the server side authentication token and the two cannot be used interchangeably. I will have to use server side authentication."

I just found it opposite. The access tokens generated by the client-side flow and server-side flow authentication are exactly same. They are "interchangeable", in fact once you get the token, it can be used anywhere as long as the user is still logged in and the token is not expired yet. This works.

curl "https://graph.facebook.com/{the user id}/friends?access_token={the token}

I cannot use client side authentication and pass the access token to my server for authentication against my system and also to be stored for further use.

Per Facebook's Securing Requests - Verifying Graph API Calls with appsecret_proof page:

Access tokens are portable. It's possible to take an access token generated on a client by Facebook's SDK, send it to a server and then make calls from that server on behalf of the person.

All this being said, I am perplexed that the SDK does not allow usage of a 3-legged OAuth flow, returning an access code instead of a token, despite their recommendation to do so for security reasons.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!