新手问题 ios 客户端进行 oauth 授权方式

shiren1118 · December 21, 2012 · 3166 hits

ios 客户端进行 oauth 授权方式

方法 1:

  • 使用 devise 做用户管理,集成 weibo 的时候使用 devise 的 omniauth 扩展,所以不需要使用微博的 ios sdk
  • UIWebview 调用/user/auth/weibo
  • rails 通过 devise 的 omniauth 扩展进入到 weibo 授权页面
  • weibo 的 callback 会回掉到 devise 的 omniauthCallback 里定义的方法
  • 这时在回掉方法里把 devise 中的 User 进行持久化。

方法 2:

使用微博的 ios sdk 获取 auth 信息,然后把 auth 信息提交到服务器,生成 devise 的 user。如果是自己写的模型就更容易了,

我是 devise 的 user 没法自己生成(密码的地方不知道如何 mock),故采用了第一种方式

user1 = User.create! :name => 'First rubychinaer', :email => '[email protected]', :password => 'rubychina', :password_confirmation => 'rubychina'

测试里好使,在 controller 里不好使,求指教

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.