pelle / oauth-plugin

Rails plugin for OAuth
http://stakeventures.com/articles/2009/07/21/consuming-oauth-intelligently-in-rails
MIT License
715 stars 215 forks source link

oauth-plugin + Rails3 + devise. #48

Closed calderonroberto closed 12 years ago

calderonroberto commented 13 years ago

I spent considerable time researching for this so I hope it helps someone:

After installing the plugin following Pelle's Readme I hit a wall with the following errors:

undefined method `callback_oauth_consumer_url' for #OauthConsumersController:0xb6652a28

Which I fixed by adding the following:

def callback super end

to oauth_consumers_controller.rb, which turned the error into:

undefined method `consumer_tokens' for #User:0xb659c7c8

It seemed like the User model was broken. Fixed it by using the gem files from the git repository. I did this by adding the following lines to my Gemfile:

gem 'devise', :git => "http://github.com/plataformatec/devise.git" gem 'oauth', :git => "http://github.com/pelle/oauth.git" gem 'oauth-plugin', :git => "http://github.com/alsemyonov/oauth-plugin.git", :branch => "rails3"

simonmorley commented 13 years ago

Hi, this is exactly the problem I've been having. Been struggling for days now and then saw your post!

Just wondering... did you need to uninstall the previous gems before installing these ones?

Also, which version on the config files did you try? I got an error saying unknown action "login_required"

Thanks

calderonroberto commented 13 years ago

Yes, uninstall the previous gem.

If you're using Rails 3, just add the line to your Gemfile and it'll uninstall and install it. What do you mean by config file? You need to define login_require as part of your login framework. I used devise (https://github.com/plataformatec/devise) which defines login_required and other methods which the oauth plugin requires. Once you install the plugin read the app/controllers/oauth_consumers_controller.rb file and uncomment appropriately.

simonmorley commented 13 years ago

Hi there,

Thanks for the answer! Much appreciated.

Managed to get it all installed and finally authenticated my services with great relief.

I seem to have run into an issue now when I call the services. I end up with:

uninitialized constant Twitter::OAuth

Have checked and checked if twitter's installed (which it is). There are no other rogue gems causing problems either.

Any chance you faced this issue and know a work around.

Simon

calderonroberto commented 13 years ago

Have you configured your twitter oauth in initializers/oauth ? You're calling the method but it's not been initialized. Let me know if you still have issues. Also check that you did follow Pelle's instructions for setting ole plugin.

stream7 commented 13 years ago

Hi, I am having the same problems. Did you manually add the routes or the generator did it for you? Also what about oauth2? Have you tried that?

calderonroberto commented 13 years ago

Manually add the routes. It should look like:

resources :oauth_consumers do
    get :callback, :on => :member
end

devise_for :user

root :to => "home#welcome"

Haven't tried OAuth2. Sorry.

stream7 commented 13 years ago

Thanks for the reply. Have you tried the provider functionality?

calderonroberto commented 13 years ago

Nope. Good luck, seems quite straight forward.

ghost commented 12 years ago

Just a big bump but I have the same problem :

undefined methodcallback_oauth_consumer_url' for #OauthConsumersController:0x007f80992020f8`

I already have your fix (it was generated). I still have this error.

Any ideas ?

P.S: I didn't do the branch switch because Rails 3 is officially supported and the Oauth gem is in my Gemlist.

ghost commented 12 years ago

Ok my bad. I just didn't add the routes :

resources :oauth_consumers do
  get :callback, :on => :member
end

Thanks a lot anyway.

calderonroberto commented 12 years ago

OK cheers.