自己使用 facebook iOS 客户端授权到服务器 [英] use facebook iOS client authorization on own to server

查看:23
本文介绍了自己使用 facebook iOS 客户端授权到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 iOS 应用中使用 facebook SSO,效果很好.现在我想在我的服务器后端使用该信息 - 用户正在使用他的 uid 对 facebook 进行验证.但是我如何 - 安全地 - 将此信息传递给服务器?

I am using facebook SSO in my iOS app and that works alright. Now I would like to use that information - the user being verified against facebook with his uid - on my server backend. But how can I - securely - pass this information to the server?

我的猜测是我需要将 uid 和可能是我从 facebook 获得的 authToken 发送到我的服务器?有人可以概述一个通用的方法吗?

My guess is that I'd need to send the uid and probably the authToken I got from facebook to my server? Could someone outline a general approach to that?

尽管这对我的问题来说并不重要,但我的服务器正在运行 Rails 并设计用于身份验证.我也有 facebook 登录单独在那里工作,但我想使用服务器上客户端已经完成的身份验证.令人困惑...

Even though it shouldn't really matter for my question, my server is running rails and devise for authentication. I also have facebook login working there separately, but I want to use the already done authentication from the client on the server. Confusing...

推荐答案

我遇到了 这篇 帮助我理解问题和解决方案的帖子.

I came across this post which helped me understand the problem and solution.

如果您发现任何问题,请纠正我.

Correct me if you see any issues.

这个想法是将 auth 令牌传递给 rails 应用程序.身份验证令牌仅在两个应用使用相同的应用机密时才有效.

The idea is to pass the auth token to the rails app. The auth token only works if both apps use the same app secret.

所以流程是这样的:

  1. iOS 身份验证.获取用户的 Facebook 身份验证令牌并发送到 rails 应用程序.
  2. Rails 应用获取身份验证令牌,将其发布到 graph.facebook.com/?auth_token=XXX.响应应该是用户的 json 对象.
  3. 获取用户对象响应以查找 UID 并将其与数据库中的用户匹配.如果 UID 不存在,请创建一个新用户并设置新的 UID.

这篇关于自己使用 facebook iOS 客户端授权到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆