pelle / oauth-plugin

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

Failing to display list of OAuth clients after authorizing a client app #109

Closed asavin closed 12 years ago

asavin commented 12 years ago

I'm getting this error when trying to access /oauth_clients after I've authorize a client app to access my account:


ActionController::RoutingError in Oauth_clients#index

Showing /home/alex/hundredthings/app/views/oauth_clients/index.html.erb where line #12 raised:

No route matches {:controller=>"oauth", :action=>"revoke"} Extracted source (around line #12):

9: <%= link_to token.client_application.name, token.client_application.url %> 10: <%= token.authorized_at %> 11: 12: <% form_tag :controller => 'oauth', :action => 'revoke' do %> 13: <%= hidden_field_tag 'token', token.token %> 14: <%= submit_tag "Revoke!" %> 15: <% end %> Rails.root: /home/alex/hundredthings

Application Trace | Framework Trace | Full Trace app/views/oauth_clients/index.html.erb:12:in block (2 levels) in _app_views_oauth_clients_index_html_erb__4342959844419038579_39707540_1970803616456943060' app/views/oauth_clients/index.html.erb:8:inblock in _app_views_oauth_clients_index_html_erb__4342959844419038579_39707540_1970803616456943060' app/views/oauth_clients/index.html.erb:7:in each' app/views/oauth_clients/index.html.erb:7:in_app_views_oauth_clients_index_html_erb__4342959844419038579_39707540_1970803616456943060'


Wonder how to fix this?

Using Rails 3.0.5 with oauth and oauth_plugin gems:

gem 'oauth', '>= 0.3.0' gem 'oauth-plugin', '>=0.4.0.pre1'

asavin commented 12 years ago

Seems like I'm missing the revoke() method in oauth controller. But I wonder why? Isn't it suppose to be part of OAuth::Controllers?

My current oauth_controller.rb looks like this:


require 'oauth/controllers/provider_controller' class OauthController < ApplicationController include OAuth::Controllers::ProviderController

def login_required authenticate_user! end

protected

Override this to match your authorization page form

It currently expects a checkbox called authorize

def user_authorizes_token?

params[:authorize] == '1'

end

should authenticate and return a user if valid password.

This example should work with most Authlogic or Devise. Uncomment it

def authenticate_user(username,password) user = User.find_by_email params[:username] if user && user.valid_password?(params[:password]) user else nil end end

end

chrisupb commented 12 years ago

Simply put post "/oauth/revoke" in routes.rb

There are several other changes to do. Look at: http://unhandledexpression.com/2011/06/02/rails-and-oauth-plugin-part-1-the-provider/ http://www.cocoalife.net/2011/02/post_866.html

asavin commented 12 years ago

Cool, thanks! Updating routes.rb worked! Thanks for useful links too.