env variables not set?
tute opened this issue · 1 comments
tute commented
Thanks for your code, aganov. I'm trying to use it but I've run into some issues. Out of the box, when I grant access to the Sinatra app, oauth2/token does not see the current user (but /me renders a user):
Started POST "/oauth2/token" for 127.0.0.1 at 2011-08-17 16:02:30 -0300
Processing by Oauth2::TokensController#create as
Parameters: {"grant_type"=>"authorization_code", "code"=>"09e3b07c2a2ebb692a961c01afecebd3", "client_id"=>"120094574673767", "client_secret"=>"[FILTERED]", "redirect_uri"=>"http://localhost:9393/oauth/callback"}
Completed in 16ms
Started POST "/users/sign_in" for 127.0.0.1 at 2011-08-17 16:02:31 -0300
Processing by Devise::SessionsController#create as
Parameters: {"grant_type"=>"authorization_code", "code"=>"09e3b07c2a2ebb692a961c01afecebd3", "client_id"=>"120094574673767", "client_secret"=>"[FILTERED]", "redirect_uri"=>"http://localhost:9393/oauth/callback"}
Completed in 61ms
Processing by Devise::SessionsController#new as
Parameters: {"grant_type"=>"authorization_code", "code"=>"09e3b07c2a2ebb692a961c01afecebd3", "client_id"=>"120094574673767", "client_secret"=>"[FILTERED]", "redirect_uri"=>"http://localhost:9393/oauth/callback"}
Rendered /Users/tute/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.2/app/views/devise/shared/_links.erb (2.2ms)
Rendered /Users/tute/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.2/app/views/devise/sessions/new.html.erb within layouts/application (13.4ms)
Completed 200 OK in 37ms (Views: 24.6ms | ActiveRecord: 0.0ms)
If I comment the before filters from the gem controllers, I get:
Started POST "/oauth2/token" for 127.0.0.1 at 2011-08-17 16:04:53 -0300
Processing by Oauth2::TokensController#create as
Parameters: {"grant_type"=>"authorization_code", "code"=>"5a76d626ab5a1d2e7e334e8c95a90d0f", "client_id"=>"120094574673767", "client_secret"=>"[FILTERED]", "redirect_uri"=>"http://localhost:9393/oauth/callback"}
Completed 500 Internal Server Error in 1ms
NoMethodError (undefined method `refresh_tokens' for nil:NilClass):
The nil object comes from Oauth2::TokensController#oauth2_current_client
, which returns env['oauth2.client']
.
Why is this happening?
Many thanks again!
TuteC.
tute commented
Discussing it on the gem's repo: socialcast/devise_oauth2_providable#13