一直很想试下 omniauth
我很菜,找到了这篇文章 http://railscasts.com/episodes/241-simple-omniauth 按其过程一路下来,注册好'CONSUMER_KEY', 'CONSUMER_SECRET'
最后 rake routes 时,说不能初始化:
uninitialized constant OmniAuth::Strategies::Twitter
查到原因是还要添加 omniauth-twitter 这个 gem
gem 'omniauth-twitter'
这时,rake routes 时: ``` /auth/:provider/callback(.:format) {:controller=>"sessions", :action=>"create"} signout /signout(.:format) {:controller=>"sessions", :action=>"destroy"}
当我访问http://localhost:3000/auth/twitter 时,成功跳转到twitter去登录,登录成功后返回时,出错:
```Started GET "/auth/twitter/callback?oauth_token=1RubhwlvzjEE9mfYIGiKD1ZIGUNBDFqgkLfV4jo6bU&oauth_verifier=OEUA0qLLZNpYunwDL1BnWSydCo4IbnUYqOCTzZ33goo" for 127.0.0.1 at 2011-11-26 22:32:30 +0800
Processing by SessionsController#create as HTML
Parameters: {"oauth_token"=>"1RubhwlvzjEE9mfYIGiKD1ZIGUNBDFqgkLfV4jo6bU", "oauth_verifier"=>"OEUA0qLLZNpYunwDL1BnWSydCo4IbnUYqOCTzZ33goo", "provider"=>"twitter"}
User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`provider` = 'twitter' AND `users`.`uid` = '18209844' LIMIT 1
Completed 500 Internal Server Error in 71ms
Started GET "/auth/failure?message=invalid_response" for 127.0.0.1 at 2011-11-26 22:32:34 +0800
ActionController::RoutingError (No route matches [GET] "/auth/failure"):