胖鸭 2011-01-07 09:11
浏览 342
已采纳

在 iOS 应用程序中设计 Facebook 身份验证,也可以访问安全的网络服务

Goal: Allow a user to authentication with Facebook into an iOS application which requires access to a protected web service that I'm running.

Assumptions: There is a native authentication (and registration) system in place for those users that opt not to use Facebook for sign in.

Details:

  • Assume we want to offer the option for a user to sign in with Facebook without creating a separate account/credential for our system.
  • Because we support our own native auth mechanism (username and password) we have our own user IDs and issue an authentication token that is used for subsequent interactions after the initial credential validation.

I'm surprised that Facebook doesn't have best practices for this in their developer documentation. All the existing documentation is either assuming you are building FB auth into a website, or a standalone mobile app with no service that requires authentication.

Here's my initial thoughts on how this would be designed but want validation on whether it's correct.

  1. Client pops the Facebook iOS Login
  2. UI User signs in with Facebook credentials and gets access token
  3. iOS App passes access token to our server
  4. Our server talks to FB graph API using access token to (a) validate the token and (b) get the FB user ID for that access token.

    e.g. Our server would call https://graph.facebook.com/me/?access_token=XYZ which would return profile info in a JSON object

  5. Assuming it's valid, our server extracts the User ID from the JSON object and checks whether the user already has an account. If so, we issue our own auth ticket to client to use for that session. If user doesn't have an account, we create a new one with the Facebook User ID, assign our own unique UserID and issue our auth ticket.

  6. Client then passes auth ticket back on subsequent interactions that need authentication.

This seems like the right approach to me but not sure if I'm missing something insanely basic and going down the wrong (complicated) path.

转载于:https://stackoverflow.com/questions/4623974/design-for-facebook-authentication-in-an-ios-app-that-also-accesses-a-secured-we

  • 写回答

4条回答 默认 最新

  • csdnceshi62 2011-01-07 13:40
    关注

    I just dealt with this myself, and here's the part that bit me:

    In your step 5... It's possible for a user to register for an account with you entirely separate from their Facebook ID, right? Then some other time they log in with Facebook.... And you just created them a second account and lost their first one.

    There needs to be a way to be logged in to your web service, then log in to facebook, and capture the association between the facebook ID and the local account.

    Apart from that, your plan sounds solid.

    Update: Facebook has added a doc outlining such a scenario HERE

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。