Reputation: 25001
I'm trying to use oauth-plugin
on a Rails
application I'm developing, but I keep running into problems.
To make sure I'm not making any mistake, I started an application from scratch (using Rails 3.0.3). Here are the steps I followed:
rails.test
)Edited its Gemfile
to include:
gem "oauth-plugin", ">=0.4.0.pre1"
gem "oauth", "0.4.4"
Generated oauth-consumer
, by running script/rails g oauth_consumer
Edited oauth_consumers.rb
to include my keys for Google integration:
:google=>{
:key=>"anonymous",
:secret=>"anonymous",
:scope=>"https://www.google.com/calendar/feeds/",
:options => {
:site => "http://www.google.com",
:request_token_path => "/accounts/OAuthGetRequestToken",
:access_token_path => "/accounts/OAuthGetAccessToken",
:authorize_path=> "/accounts/OAuthAuthorizeToken"
},
}
Edited routes.rb
to add the route for oauth_consumer
:
resources :oauth_consumers
Edited application_controller.rb
to implement the logged_in?
method as follows:
def logged_in?
true
end
Now when I access http://localhost:3000/oauth_consumers/google
I get the following error:
uninitialized constant GoogleToken
Does anyone know what causes this error and how can I fix it? GoogleToken
is a class that should have been auto generated by oauth-plugin
, so I can't tell why I'm getting this uninitialized constant error.
Upvotes: 3
Views: 1225
Reputation: 31
The GoogleToken class doesn't get auto-generated unless you pass "google" to the generator like so:
script/rails g oauth_consumer google
or for rails 3:
rails g oauth_consumer google
Also check to ensure the relationship is set up in the user model like so:
has_one :google, :class_name => "GoogleToken", :dependent => :destroy
Upvotes: 3
Reputation: 383
I have the same problem, i think a solution could be in this: https://github.com/pelle/oauth-plugin/blob/master/lib/generators/oauth_consumer/USAGE You need some sort of authentication like restful-authentication plugin, if you uncomment line 27..29 in your oauth_consumers_controller.rb file, you'll jump to next step!
Upvotes: 0
Reputation: 6642
Did you remember to run bundle install
from terminal after editing your Gemfile
? Sounds like your Rails app doesn't know about these gems yet.
Upvotes: 0