Code Monkey home page Code Monkey logo

oauth-plugin's Issues

Proper bundler support.

Hello,

When you add to the Gemfile:
gem 'oauth-plugin', '~> 0.4.1.pre1'

It requires the lib/oauth-plugin.rb by default (which is empty). And there's no way to require rails/init, because it is outside of the lib directory.

Could you move the rails/init.rb file to the lib directory? So at least I could write something like:
gem 'oauth-plugin', '~> 0.4.1.pre1', :require => 'oauth/rails'

Thank you,

authlogic

Hi,
have you tested your plugin with authlogic? Will it works?

RecordNotFound is undefined

When I try to disconnect a user who is already disconnected from an oauth service I get the following:

uninitialized constant Oauth::Controllers::ConsumerController::RecordNotFound
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:440:in load_missing_constant' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:inconst_missing'
/myapp/vendor/plugins/oauth-plugin/lib/oauth/controllers/consumer_controller.rb:49:in `destroy'

Invalid OAuth request

Hello and sorry for my English.
I am using oauth 0.4.4 and oauth-plugin 0.4.0.pre4 gems.
When i trying to access my app as an OAuth Provider
8 consumer = OAuth::Consumer.new consumer_key, consumer_secret,
9 :site => 'http://localhost:3000/', :scheme => :body
10
11 request_token = consumer.get_request_token
consumer raises an exception
/home/lain/.rvm/gems/ruby-1.9.2-p136/gems/oauth-0.4.4/lib/oauth/consumer.rb:217:in token_request': 401 Unauthorized (OAuth::Unauthorized) from /home/lain/.rvm/gems/ruby-1.9.2-p136/gems/oauth-0.4.4/lib/oauth/consumer.rb:139:inget_request_token'
from private/test_app.rb:11:in `

'

Rails log for this request is

Started POST "/oauth/request_token" for 127.0.0.1 at 2011-02-22 21:17:54 +0300
  Processing by OauthController#request_token as */*
  Parameters: {"oauth_body_hash"=>"2jmj7l5rSw0yVb/vlWAYkK/YBwk=", "oauth_callback"=>"oob", "oauth_consumer_key"=>"GAdP34UY4zunPwhm9hePODITteHxplQ3oShNPuKs", "oauth_signature_method"=>"HMAC-SHA1", "oauth_timestamp"=>"1298398673", "oauth_nonce"=>"aDRQijPyYJYODaqdZvpD2RMrReixMVcWb0zYSpjI", "oauth_version"=>"1.0", "oauth_signature"=>"0kYXwbPnNZK7JLpVVtnLs+H5klQ="}
Rendered text template (0.0ms)
Completed 401 Unauthorized in 10ms (Views: 2.7ms | ActiveRecord: 0.0ms)

When I trying to simulate this request using curl, I'm going to get

$ curl 'http://127.0.0.1:3000/oauth/request_token' -d 'oauth_body_hash=2jmj7l5rSw0yVb%2fvlWAYkK%2fYBwk%3d&oauth_callback=oob&oauth_consumer_key=GAdP34UY4zunPwhm9hePODITteHxplQ3oShNPuKs&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1298398673&oauth_nonce=aDRQijPyYJYODaqdZvpD2RMrReixMVcWb0zYSpjI&oauth_version=1.0&oauth_signature=0kYXwbPnNZK7JLpVVtnLs%2bH5klQ%3d' -v
* About to connect() to 127.0.0.1 port 3000 (#0)
*   Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> POST /oauth/request_token HTTP/1.1
> User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: 127.0.0.1:3000
> Accept: */*
> Content-Length: 309
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 401 Unauthorized 
< Access-Control-Allow-Origin: *
< Content-Type: text/html; charset=utf-8
< Cache-Control: no-cache
< X-Ua-Compatible: IE=Edge
< X-Runtime: 1.245471
< Server: WEBrick/1.3.1 (Ruby/1.9.2/2010-12-25)
< Date: Tue, 22 Feb 2011 23:57:49 GMT
< Content-Length: 21
< Connection: Keep-Alive
< 
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
Invalid OAuth Request

My database contains one ClientApplication
ruby-1.9.2-p136 :001 > ClientApplication.all.to_a
=> [#<ClientApplication _id: 4d62f535e4279b2dec000001, created_at: 2011-02-21 23:28:53 UTC, updated_at: 2011-02-21 23:28:53 UTC, name: "...", url: "...", support_url: nil, callback_url: nil, key: "GAdP34UY4zunPwhm9hePODITteHxplQ3oShNPuKs", secret: "EQAD5fifIuC3qtAyrkIpqAEn39rK50Az55gxbVYD", user_id: nil>]

I had tried many versions of oauth and oauth-plugin but I never got any successful result.
Two test consumers I had googled for `oauth test' show me the same:
http://term.ie/oauth/example/client.php
http://dev.k42b3.com/index.php/oauth/consumer

I'm using devise 1.2.rc but I have disabled it by skip_before_filter :authenticate_user! in both Application and Oauth controllers.

Rails 2.0.2 generate oauth_consumer gives errors

On Rails 2.0.2 & Ruby 1.8.7

running script/generate oauth_consumer give the error

/vendor/plugins/oauth-plugin/lib/oauth-plugin.rb:6: undefined method `version' for Rails:Module (NoMethodError)

Removing the rails 3 version check, running the script again then gives

/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:263:in load_missing_constant': uninitialized constant Rails::Railtie (NameError) vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:453:inconst_missing'
from /u/apps/netadventist3/current/vendor/plugins/oauth-plugin/lib/oauth-plugin.rb:16

Unfortunately the app I'm extending has Rails 2.0.2 frozen in

Validation failed - Client application can't be blank

I'm new to rails and ruby in general, but I may be running into an issue with the oauth-plugin itself. I'm attempting to use the consumer portion of the logic to authorize my web app via a user's Twitter account. Everything is setup to the point that I'm redirected to Twitter for the authorization, but when the user is redirected back to my app, I receive an error when the token is being saved into the MongoDB database:

Mongoid::Errors::Validations in Oauth consumersController#callback

Validation failed - Client application can't be blank.

It seems the Token model is expecting a "Client application" property to be populated, but I can't find this property anywhere.

One thing to note is I'm using the latest branch which includes fixes by 3en for mongoid, but the only way I can get the models to work is by using 'referenced_in' instead of 'embedded_in'.

What am I doing wrong here? Thanks in advance. -Rob

Application trace:

app/models/consumer_token.rb:25:in find_or_create_from_access_token'
app/controllers/oauth_consumers_controller.rb:16:in callback'

Partial full trace:

vendor/ruby/1.8/gems/mongoid-2.0.0.rc.7/lib/mongoid/persistence.rb:234:in fail_validate!'
vendor/ruby/1.8/gems/mongoid-2.0.0.rc.7/lib/mongoid/persistence.rb:75:in save!' vendor/ruby/1.8/gems/mongoid-2.0.0.rc.7/lib/mongoid/relations/referenced/many.rb:90:in create!'
vendor/ruby/1.8/gems/simple_oauth-0.1.4/lib/simple_oauth/core_ext/object.rb:6:in tap' vendor/ruby/1.8/gems/mongoid-2.0.0.rc.7/lib/mongoid/relations/referenced/many.rb:89:in create!'
app/models/consumer_token.rb:25:in find_or_create_from_access_token' vendor/ruby/1.8/bundler/gems/oauth-plugin-f805e8c359b1/lib/oauth/models/consumers/token.rb:38:in find_or_create_from_request_token'
vendor/ruby/1.8/bundler/gems/oauth-plugin-f805e8c359b1/lib/oauth/controllers/consumer_controller.rb:35:in callback' app/controllers/oauth_consumers_controller.rb:16:in callback'`

Edit: More info - after stepping into the framework code, I can see that the Token class is expecting a client_application_id to have a value. I didn't think a consumer token needed to be associated with a client application?

Consumer Issue with versions >= 0.4.0 pre-3 (Mongoid)

I noticed this issue appears in 0.4.0 pre-3 and in 0.4.0 pre-4 with Mongoid. For debugging purposes I am using 0.4.0 pre-4.

I destroyed and re-generated oauth_consumer

The following error occurs even with the newly generated oauth_consumer_controller:

Unknown action
The action 'callback' could not be found for OauthConsumersController

If I add (to oauth_consumer_controller):

def callback
    super
end

The error results in:

can't convert Hash into Integer

app/models/consumer_token.rb:26:in `find_or_create_from_access_token'
app/controllers/oauth_consumers_controller.rb:16:in `callback'

Also just to double check as I belive this is not documented anywhere but looking at the generated ConsumerToken model I have defined the Mongoid relationship in User as "embeds_many :consumer_tokens". I believe this is right.

Any idea what's causing this. I believe it's only a problem since 0.4.0 pre-3

OAuth Invalid Request on POST and not GET. Why?

We're getting weird issues with our consumers where GET requests protected by oauth work great, but POST are always getting OAuth Invalid Requests. I've tried having them switch from query_string to auth headers, and vice versa but still not working.

Any ideas about this?

Updated twitter_token.rb for latest twitter gem

Hi

Your recent commit to incorporate the latest Twitter gem was still not working for me. I've modified twitter.rb controller with the following:

require 'twitter'
class TwitterToken < ConsumerToken
  TWITTER_SETTINGS={:site=>"http://api.twitter.com", :request_endpoint => 'http://api.twitter.com',}
  def self.consumer
    @consumer||=OAuth::Consumer.new credentials[:key],credentials[:secret],TWITTER_SETTINGS
  end

  def client
    Twitter.configure do |config|
      config.consumer_key = TwitterToken.consumer.key
      config.consumer_secret = TwitterToken.consumer.secret
      config.oauth_token = token
      config.oauth_token_secret = secret
    end
    @client ||= Twitter::Client.new
  end
end

I hope this helps someone, I was stuck for hours..

no such file to load -- activesupport

Using rails3 branch, after installing plugin and running the generator:

rake db:migrate
rake aborted!
no such file to load -- activesupport

(See full trace by running task with --trace)

CreateOauthTables migration buggy

When running ./script/generate oauth_provider a migration for nessecary tables is generated. The indexes that are created should be uniqe
add_index :client_applications, :key, :unique

Correct Syntax is:
add_index :client_applications, :key, :unique => true

Name required in generator

Basically all of the examples give the syntax as "rails g oauth_provider", but this gives an error and never produces views:

rails g oauth_provider
      invoke  active_record
      create    app/models/client_application.rb
      create    app/models/oauth_token.rb
      create    app/models/request_token.rb
      create    app/models/access_token.rb
      create    app/models/oauth2_token.rb
      create    app/models/oauth2_verifier.rb
      create    app/models/oauth_nonce.rb
      create    db/migrate/20110210222633_create_oauth_tables.rb
      create  app/controllers/oauth_controller.rb
      create  app/controllers/oauth_clients_controller.rb
      invoke  test_unit
      create    test/oauth_controller_test_helper.rb
      create    test/functional/oauth_controller_test.rb
      create    test/functional/oauth_clients_controller_test.rb
      create    test/unit/client_application_test.rb
      create    test/unit/oauth_token_test.rb
      create    test/unit/oauth_nonce_test.rb
      invoke  erb
No value provided for required arguments 'name'
Loaded suite script/rails
Started

Finished in 0.000163 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

As you can see, it dies right after "invoke erb". On the other hand, if you use "rails g oauth_provider provider" it will generate the rest without a complaint.

(running on Rails 3.0.3, Ruby 1.8.6)

TypeError when finding oauth token(Mongoid)

When requesting a request token, i get an error:
TypeError (can't convert Hash into Integer):
app/models/client_application.rb:48:in `verify_request'
I backtraced in and figured out that the error is from oauth/rack/oauth_filter.rb:31
oauth_token = client_application.tokens.first(:conditions=>{:token => request_proxy.token})
I think it should be something like this:
oauth_token = client_application.tokens.where(:conditions=>{:token => request_proxy.token}).first

oauth_token_test fails (missing provided_oauth_verifier)

Hi,

I ran the unit tests after doing a script/generate oauth_provider --test-unit, 2 small issues in the file test/unit/oauth_token_test.rb generated:

1 - there are 2 tests named "test_should_not_exchange_without_approval", I renamed the second one to "test_should_exchange_with_approval"
2 - line 48 of the file, a provided_oauth_verifier should be set after the @token.authorize!
Here is what i did to pass the test:

@token.authorize!(users(:user_2))
@token.provided_oauth_verifier = @token.verifier
@access = @token.exchange!

I thought this might help for other users :) And many thanks for the nice work on this gem

Cheers,

Maxime

PS: i'm under Ruby 1.9.1 with the gems oauth (0.4.0) and oauth-plugin (0.3.14)

retrieving credentials from ConsumerToken

So inside of the TwitterToken#client method, I am getting the follow error when trying to authorize:

undefined local variable or method `credentials' for #<TwitterToken:0x420ce6ac>

I threw in some debugger statements and was strangely able to access credentials from within TwitterToken.consumer - i.e. only from the class but not from the instance. Any idea how I might get around this? I tried self.class.credentials, but no dice.

Model Name Change No Affect

Hi

I've changed my model name from user to page, ran the migration and oauth-plugin is still executing for user model...

The error it throws is as follows"

SQLite3::SQLException: no such column: consumer_tokens.user_id: SELECT "consumer_tokens".* FROM "consumer_tokens" WHERE "consumer_tokens"."type" = 'TwitterToken' AND "consumer_tokens"."user_id" = '1' LIMIT 1

Can anyone assist with this?

Simon

undefined method `consumer_tokens'

I've been having a few issues with getting the consumer working properly. I first had to run the generator with any extra parameter to get it to generate the views, I then had to add the references routes manually:

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

As well as the callback method to the controller:

def callback
    super
end

I've created my own token class to support Dopplr (pretty much a copy of the TwitterToken class)

require 'dopplr'
class DopplrToken < ConsumerToken
  TRIPIT_SETTINGS={
    :site=>"https://www.dopplr.com",
  }

  def self.consumer
    @consumer||=OAuth::Consumer.new credentials[:key],credentials[:secret],TRIPIT_SETTINGS
  end

  def self.client
    unless @client
      @dopplr_oauth=Dopplr::OAuth.new DopplrToken.consumer.key,DopplrToken.consumer.secret
      dopplr_oauth.authorize_from_access token,secret
      @client=Dopplr::Base.new(@dopplr_oauth)
    end

    @client
  end
end

I've added the line to the user model:

has_one :dopplr, :class_name=>"DopplrToken", :dependent=>:destroy

But now I get this error when I'm redirected to the callback URL:

Undefined method `consumer_tokens' for #<User:0x103335848>

Adding has_many :consumer_tokens to the user model made the callback work, but now there's 'Consumer' listed on the index page, rather than identifying it as Dopplr. Is there something wrong with the callback method that doesn't identify the service class properly?

Cohabitating oauth-plugin with authlogic-connect yields naming conflicts

I've got a site which uses the authlogic-connect gem for Facebook/Twitter OAuth authentication. When I run the ouath-plugin generator, I get this:

$ >> rails g oauth_provider
      invoke  active_record
The name 'AccessToken' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.

I wouldn't take issue with renaming AccessToken, but unfortunately that model is buried within the authlogic-connect gem.

Perhaps we could parameterize the AccessToken class name in the generator?

no routes defined by the generators

Hi,

I get no routes defined after running the generators (for both consumer/producer).
Even if I define the basic routes for my oauth_consumers_controller the named routes of the lib/oauth/controllers/consumer_controller (and the rest of course) remain undefined.

I'm using ruby 1.8.7 MRI and rails 3.0.4.

Any ideas what the problem might be?

Index key length in migration

There is a problem running the migration, due to key length which is too long if the table use utf-8:

== CreateOauthConsumerTokens: migrating ======================================
-- create_table(:consumer_tokens)
-> 0.0780s
-- add_index(:consumer_tokens, :token, {:unique=>true})
rake aborted!
Mysql::Error: Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX index_consumer_tokens_on_token ON consumer_tokens (token)

I don't know how to fix this in a ruby-way, but this sql does the trick:
execute("CREATE UNIQUE INDEX index_consumer_tokens_on_token ON consumer_tokens (token (100))")

It uses only the 100 first chacracters instead of the whole field.

Mongoid Issue with @provider.find_by_key etc

The issue is same
https://github.com/pelle/oauth-plugin/issues/closed/#issue/27

lib/oauth/controllers/application_controller_methods.rb
80 @oauth2_token = Oauth2Token.find_by_token(token)
139 @client_application = ClientApplication.find_by_key(request_proxy.consumer_key)

lib/oauth/controllers/provider_controller.rb
35 @client_application = ClientApplication.find_by_key params[:client_id]
53 @token = ::RequestToken.find_by_token params[:oauth_token]
61 @token = current_user.tokens.find_by_token params[:token]
122 @client_application = ClientApplication.find_by_key params[:client_id]
152 @client_application = ClientApplication.find_by_key params[:client_id]
182 @verification_code = @client_application.oauth2_verifiers.find_by_token params[:code]

Mongoid does not recognise this.
undefined method find_by_xxx....

Solution is to override or change this line to
find(:first,:conditions=>{:xxx=>....})
or
where(:xxx=>...).first

The action 'callback' could not be found for OauthConsumersController

Hi~
I want to connect with an oauth provider. I follow the instruction step by step, however on the redirected path (/oauth_consumers/sina/callback) I get an "Unknown action" error (The action 'callback' could not be found for OauthConsumersController).

What should I do?
Thanks a lot!

views and routes not getting created on generate oauth_provider

It seems that when i run rails g oauth_provider i get the following:

$ /usr/local/bin/rails g oauth_provider
invoke mongoid
create app/models/client_application.rb
create app/models/oauth_token.rb
create app/models/request_token.rb
create app/models/access_token.rb
create app/models/oauth2_token.rb
create app/models/oauth2_verifier.rb
create app/models/oauth_nonce.rb
create app/controllers/oauth_controller.rb
create app/controllers/oauth_clients_controller.rb
invoke test_unit
create test/oauth_controller_test_helper.rb
create test/functional/oauth_controller_test.rb
create test/functional/oauth_clients_controller_test.rb
create test/unit/client_application_test.rb
create test/unit/oauth_token_test.rb
create test/unit/oauth_nonce_test.rb
invoke erb
No value provided for required arguments 'name'

but it seems to skip generation of the views and routes that it seems should be created when i look at the generator https://github.com/pelle/oauth-plugin/blob/rails3/generators/oauth_provider/oauth_provider_generator.rb

here is the relevent info from my gem file:
gem 'rails', '3.0.4'
gem 'mongoid', '2.0.0.beta.20'
gem 'bson_ext', '>= 1.2.1'
gem 'devise', '1.1.3'
gem 'oauth', :git => "http://github.com/pelle/oauth.git", :require => 'oauth/server'
gem "oauth-plugin", :git => 'https://github.com/pelle/oauth-plugin.git', :branch => 'rails3'

Any ideas?

oAuth2 Support for Rails 2.3.5?

Hi there,

i'm currently evaluating the use of an oauth gem to have oAuth Provider functionality. I saw that oAuth 2 ist supported in your gem, but only in the branch "rails3". Is the code in this branch somewhat compat to rails 2 or is support for oAuth 2 planned in the master branch?

Thanks for your help

Desktop Applications

Hey,

great work on the gem!
One question though: Will it also work with Desktop Applications (which don't have a callback_url but normally exchange the request token for the access token, once the user closes the browser window (where he/she authorized the desktop app))?

Ruby 1.9.2, Rails 3.0.7: Cannot install oauth-plugin

Hello, I'm trying to install the auth-plugin by following the instructions, but I get the following error after adding

gem "oauth-plugin", ">=0.4.0.pre1" to Gemfile and running bundle install

cp: /home/users/dimitar/.bundler/tmp/1074/gems/oauth-plugin-0.4.0.pre4 and /home/users/dimitar/.bundler/tmp/1074/gems/oauth-plugin-0.4.0.pre4 are identical (not copied).
cp: /home/users/dimitar/.bundler/tmp/1074/specifications/oauth-plugin-0.4.0.pre4.gemspec and /home/users/dimitar/.bundler/tmp/1074/specifications/oauth-plugin-0.4.0.pre4.gemspec are identical (not copied).

bundle show gives out:

Gems included by the bundle:
Could not find oauth-plugin-0.4.0.pre4 in any of the sources

If I go with just gem "oauth-plugin" in the Gemfile, the gem installs okay, but then I am unable to generate OAuth and OAuth controllers:

$ rails generate oauth_consumer
Could not find generator oauth_consumer.

Any suggestions?

oauth-plugin + Rails3 + devise.

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"

RequestToken.exchange! seems to be broken in latest version 0.3.14

this line: return false unless oauth10? || verifier==provided_oauth_verifier

expects "oauth10?" to return false i guess. forcing me to declare OAUTH_10_SUPPORT in my environment.rb and set it to false before any access_token requests can be handed out. I couldn't find this anywhere in the documentation. I'm using authlogic but why should that matter? Anyway i'm just a beginner but after a day of debugging i came to the conclusion that maybe this is a bug?

No such file to load, uninitialized constant

Hi,

Many thanks for your working around oauth.

I was realy excited to use this gem but I had 2 major problem for using the oauth consumer.

  1. (resolved) It's write anywhere in doc that the rails generate commande line should have a additional argument to working, otherwise this error occurs and stop process

    C:\oauth_plugin>rails g oauth_consumer
      invoke  active_record
      create    app/models/consumer_token.rb
      create    db/migrate/20101214142735_create_oauth_consumer_tokens.rb
      create  config/initializers/oauth_consumers.rb
      create  app/controllers/oauth_consumers_controller.rb
      invoke  erb
    No value provided for required arguments 'name'
    

    Change "rails g oauth_consumer" to "rails g oauth_consumer oauth" to avoid errror. (I don't know where this arguement is used ??!? ).

  2. An then, when I have setup my oauth controller, oauth model and OAUTH_CREDENTIALS. I have the following error on url http://127.0.0.1:3000/oauth_consumers/

    LoadError in Oauth consumersController#index
    
    

no such file to load -- json

And when I'm going to http://127.0.0.1:3000/oauth_consumers/google :

NameError in Oauth consumersController#show

uninitialized constant GoogleToken

I'm a forum explorer rather than ruby senior developper, So I didn't found any post about this problem relative to oauth_plugin. Can you please help me ?

My config:
Windows 7
ruby 1.8.7
rails 3.0.3
oauth 0.4.4
oauth-plugin 0.4.0.pre3

Specified key was too long; max key length is 767 bytes

consumer_tokens table
t.string :token, :limit => 1024 # This has to be huge because of Yahoo's excessively large tokens
change to :
t.string :token, :limit => 128
:(
ERROR 1071 (42000): Specified Key was too Long; Max Key Length is 767 Bytes.

OAuth-plugin assumes OAuth credentials should be associated with User model

We would like to use the OAuth-plugin gem for a model other than User. Looking at the code, we are unsure what it would take to modify the codebase to support such a feature. We were hoping for some guidance on whether or not the architecture can even tolerate such an adaptation (for example, we noticed it depends on current_user).

Can you offer insight into:

  • Whether this configurability is a planned feature
  • How to go about taking a stab at adapting the code base

Thanks!

Ruby 1.9.1. issue

I get this error in ruby 1.9.1 calling out to an authentication url. This works in ruby 1.8.7

TypeError in Oauth consumersController#show

can't dup Symbol

RAILS_ROOT: C:/sites/bizii
Application Trace | Framework Trace | Full Trace

C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1529:in dup' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1529:inurlencode'
C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1524:in block in encode_kvpair' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1524:inmap'
C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1524:in encode_kvpair' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1517:inblock in set_form_data'
C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1517:in each' C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1517:inmap'
C:/Ruby19/lib/ruby/1.9.1/net/http.rb:1517:in set_form_data' C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:324:increate_http_request'
C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:176:in create_signed_request' C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:149:inrequest'
C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:183:in token_request' C:/Ruby19/lib/ruby/gems/1.9.1/gems/oauth-0.3.6/lib/oauth/consumer.rb:128:inget_request_token'

Trusted sites

Hi,
Is there any ability to mark site as trusted? For example - somebody have some sites - auth.site.com (as oauth provider) and s1.site.com, s2.site.com etc as consumers. Of course - owner would like to skip step "Do you agree to add site s1.site.com as trusted?", but for security reason would like to not mark other sites like othersite.com, othersite2.com as trusted. I'm planning to add this functionality to plugin, but i'd like to discuss how to develop with you, because i'm a newbie in oauth. Any ideas? From my understanding - there are need to add password for Request Token and if password is not present - use default callflow. Maybe you have another vision of this?

Rails lazy class loading and defined?(Oauth2Token)

Hi,
when setting up oauthentication with your plugin i stumbled across Rails lazy Class loading. In your application_controller_methods is the following method:

def oauth20_token
return false unless defined?(Oauth2Token)
[...]

When the class was not loaded yet, this method returns and tells the client OAuth failed.
If i log
RAILS_DEFAULT_LOGGER.debug(defined?(Oauth2Token))
RAILS_DEFAULT_LOGGER.debug(Oauth2Token)
RAILS_DEFAULT_LOGGER.debug(defined?(Oauth2Token))
the class gets autoloaded (of course) and OAuth works as expected both on the server and client.

My question is: is the only workaround to eager load or require the Oauth2Token-Class? Or is this supposed to work otherwise?

Thanks again in advance for your help

ouath2_authorize.html.erb issues and won't redirect back to client app's url...

hi.

I have to comment out oauth2_authorize.html.erb in order for it to "work" (i.e., show up)

<%# link_to @token.client_application.name,@token.client_application.url %> (<%# link_to @token.client_application.url,@token.client_application.url %>

So @token is being passed as Nil::NIlClass and that doesn't have an associaiton. So the only way to get passed this was for me to comment them out.

Now, i think the same @token being nil is effecting the second part.

In the oauth2_authorize.html.erb file, I can "authorize" the app , but after clicking submit it doesn't redirect me back to my original app.com/auth/whatever/callback like it should.

Using omniauth's provider :oauth2 I think I'm setting it up right, but they don't have a spec to copy from in their tests... so maybe they send the url different. See, I tried oauth as the provider and I'd get back to my callback url, but there were other issues that screwed that up.

I'll take any help. thanks.

This plugin requires the portablecontacts gem

Why does this require the portablecontacts gem? Shouldn't it be the other way around? In any case, I didn't want to include the portablecontacts gem in my application, but I'm forced to unless I fork this project.

Rspec Testing 160 Routing Errors

Oauthorized Controller is the routing errors and it has to do with uncommenting 1 line in your routes.rb file
Make sure the following is at the end of the routes.rb file
match ':controller(/:action(/:id(.:format)))'

This is legacy but will make the tests pass. Now i have 5 more errors to resolve on the rspec tests with rails 3.

Implementation of application_controller_methods#oauth20_token correct?

I just stumbled upon these lines of code and wondered if they are correct.

In my case i invalidated an access_token (Oauth2) - but oauthenticate would still throw no 401 or alike - it just didn't set current_token (and therefore also didn't set a "current_client_application", which resulted in 500 errors in my views).

I scanned the implementation:

def oauth20_token
      return false unless defined?(Oauth2Token)
      token, options = token_and_options
      token ||= params[:oauth_token] || params[:access_token]
      if !token.blank?
        @oauth2_token = Oauth2Token.find_by_token(token)
        if @oauth2_token && @oauth2_token.authorized?
          controller.send :current_token=, @oauth2_token
        end
      end
      @oauth2_token!=nil
    end

shouldn't the last line read?

@current_token!=nil

Callback Issue

Hi,

I've added:

def callback
super
end

Into my controller file and can now connect to twitter. However, it sends the request back to:

NoMethodError in OauthConsumersController#callback

undefined method `consumer_tokens' for #User:0x0000010276ba80

I'm really not sure what's happening?

Thanks

Simon

Shouldn't rails generate oauth_provider also generate views?

Trying to use oauth-plugin with Rails 3 application. When running rails generate oauth_provider I get models and controllers generated successfully. But no views. Those are missing completely, though I think they should be generated as well. At least according to this tutorial: http://stakeventures.com/articles/2007/11/26/how-to-turn-your-rails-site-into-an-oauth-provider

Gemfile:

gem 'rails'
gem 'simple_form'
gem 'paperclip', '~> 2.3'
gem 'devise', '1.2.rc'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'jquery-rails', '>= 0.2.6'
gem 'oauth'
gem 'oauth-plugin', '>=0.4.0.pre1'

These are generated:
invoke active_record
identical app/models/client_application.rb
identical app/models/oauth_token.rb
identical app/models/request_token.rb
identical app/models/access_token.rb
identical app/models/oauth2_token.rb
identical app/models/oauth2_verifier.rb
identical app/models/oauth_nonce.rb

Wonder is it an issue?

Rails 2 can't find Railtie constant

Following the instructions for Rails 2.3.10 (although I am using Bundler in my rails 2 app):

# Gemfile
gem 'oauth', '~> 0.4.4'
gem "oauth-plugin", ">= 0.4.0.pre1"

$ bundle install
$ ./script/generate oauth_provider --test-unit --haml

Results in:

/Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.10/lib/active_support/dependencies.rb:466:in `load_missing_constant': uninitialized constant Rails::Railtie (NameError)
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-2.3.10/lib/active_support/dependencies.rb:106:in `const_missing'
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/oauth-plugin-0.4.0.pre4/lib/oauth-plugin.rb:16
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
    from /Users/nesquena/Documents/Development/Miso/miso-server/config/environment.rb:14
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/rails-2.3.10/lib/initializer.rb:111:in `run'
    from /Users/nesquena/Documents/Development/Miso/miso-server/config/environment.rb:10
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/rails-2.3.10/lib/commands/generate.rb:1:in `require'
    from /Users/nesquena/.rvm/gems/ree-1.8.7-2010.02/gems/rails-2.3.10/lib/commands/generate.rb:1
    from ./script/generate:3:in `require'
    from ./script/generate:3

Looks like the Railtie is defined even in Rails 2 where the definition doesn't make sense.

Could not find "oauth2_webserver_authorize.html.erb" in any of your source paths.

Hey,
i've started a Rails3 application and i'm hoping to turn it into an OAuth provider application.

I have the following specified in my Gemfile:

gem 'oauth'
gem 'oauth-plugin', :git => 'git://github.com/pelle/oauth-plugin.git', :branch => 'rails3'

and i ran 'bundle install' and got the following gems installed:

Using oauth (0.4.1)
Using oauth-plugin (0.3.14) from git://github.com/pelle/oauth-plugin.git (at rails3)

I then ran the generator command 'rails g oauth_provider' and got a bunch of generated files:

  create  app/models/client_application.rb
  create  app/models/oauth_token.rb
  create  app/models/request_token.rb
  create  app/models/access_token.rb
  create  app/models/oauth2_token.rb
  create  app/models/oauth2_verifier.rb
  create  app/models/oauth_nonce.rb
  create  app/controllers/oauth_controller.rb
  create  app/controllers/oauth_clients_controller.rb
   route  match '/oauth',               :to => 'oauth#index',         :as => :oauth
   route  match '/oauth/authorize',     :to => 'oauth#authorize',     :as => :authorize
   route  match '/oauth/request_token', :to => 'oauth#request_token', :as => :request_token
   route  match '/oauth/access_token',  :to => 'oauth#access_token',  :as => :access_token
   route  match '/oauth/token',         :to => 'oauth#token',         :as => :token
   route  match '/oauth/test_request',  :to => 'oauth#test_request',  :as => :test_request
   route  resources :oauth_clients
  create  spec/models/client_application_spec.rb
  create  spec/models/oauth_token_spec.rb
  create  spec/models/oauth2_token_spec.rb
  create  spec/models/oauth2_verifier_spec.rb
  create  spec/models/oauth_nonce_spec.rb
  create  spec/fixtures/client_applications.yml
  create  spec/fixtures/oauth_tokens.yml
  create  spec/fixtures/oauth_nonces.yml
  create  spec/controllers/oauth_controller_spec_helper.rb
  create  spec/controllers/oauth_controller_spec.rb
  create  spec/controllers/oauth_clients_controller_spec.rb
  create  app/views/oauth_clients/_form.html.erb
  create  app/views/oauth_clients/new.html.erb
  create  app/views/oauth_clients/index.html.erb
  create  app/views/oauth_clients/show.html.erb
  create  app/views/oauth_clients/edit.html.erb
  create  app/views/oauth/authorize.html.erb

and at the end i got 'Could not find "oauth2_webserver_authorize.html.erb" in any of your source paths.'

any ideas?

two-legged?

Has anyone modified this to support two-legged oauth?
Any tips/advice/code?

oauth2 consumer support for Rails3

Hi

Just wondering if adding oAuth2 consumer support is on the roadmap for the rails3 branch and if so when you think it might be available? I see it's there for providers, but looks like it's not for consumers.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.