ideaoforder
ideaoforder

Reputation: 1023

Ruby Oauth-plugin Authorization Not working

I'm using the Ruby oauth-plugin (version 0.4.0.pre7) to make my Rails (3.0.3) app an oauth provider. The install worked fine, and I think the provider aspect is working fine as well. However, I'm getting stuck at the authorization stage.

Here's what I'm doing, post-install:

  1. Create an oauth client
  2. @consumer = OAuth::Consumer.new "consumer_key", "consumer_secret", {:site => "http://localhost:3000"}
  3. @request_token = @consumer.get_request_token
  4. @request_token.authorize_url
  5. Paste the URL it returns into my browser.

I receive an error: 'wrong number of arguments (0 for 2)'

I can see from the code that the query is looking this up:

SELECT `oauth_tokens`.* FROM `oauth_tokens` WHERE (`oauth_tokens`.`type` = 'Oauth2Token') AND (invalidated_at IS NULL AND authorized_at IS NOT NULL and token = 'XXXTOKENXXX') LIMIT 1

The problem seems to be that it's looking for an 'Oauth2Token' but on inspecting my DB, all the requests are creating a 'RequestToken'.

Am I missing some step in the authorization connection process? Do I have something configured incorrectly? It seems like somehow there is some conflict between Oauth versions (like the request is being generated for 1.0 and the auth is using 2.0).

Any ideas?

UPDATE: I was following this tutorial: http://unhandledexpression.com/2011/06/02/rails-and-oauth-plugin-part-1-the-provider/, and there was a typo. Another user was kind enough to post the fix in the comments, but the author never updated the tutorial.

For the record, the problems was alias :login_required :authenticate_user should have been alias :login_required :authenticate_user!

Upvotes: 1

Views: 304

Answers (1)

ideaoforder
ideaoforder

Reputation: 1023

The author has kindly updated the plugin:

http://unhandledexpression.com/2011/06/02/rails-and-oauth-plugin-part-1-the-provider/

Thanks!

Upvotes: 1

Related Questions