instructure / ims-lti

A Ruby library to help implement IMS LTI tool consumers and providers
MIT License
199 stars 122 forks source link

OAuth::RequestProxy::UnknownRequestType (ActionDispatch::Request): #89

Closed Lukahm closed 7 years ago

Lukahm commented 8 years ago

I did update for rails app form 4 to 5 recently.

Then IMS::LTI::ToolProvider is not working properly.

Here is the code:


    private_key = res[:body]["private_key"]
    provider = IMS::LTI::ToolProvider.new(public_key, private_key, params.to_unsafe_h)
    unless provider.valid_request?(request)
      if provider.context_student? || provider.institution_student?
        return render :participant_wait_for_activity
      else
        return render :invalid_key
      end
    end

I got an error when provider.valid_request?(request) is excuted.

Here is the error: OAuth::RequestProxy::UnknownRequestType (ActionDispatch::Request):

austinmbrown commented 8 years ago

I'm running into this as well.

bracken commented 8 years ago

Here is a link to your OAuth gem ticket for reference: https://github.com/oauth-xx/oauth-ruby/issues/131

abutterf commented 8 years ago

Did you recently update the ims-lti gem? There was a breaking change in the 2.1.0.beta.x version of the gem.

bracken commented 8 years ago

I commented in the OAuth gem, I think I found the problem. Rails 5's request object is no longer a Rack::Request.

bracken commented 8 years ago

A comment in the other one points out there is already a proxy that works, just use require 'oauth/request_proxy/action_controller_request' instead of require 'oauth/request_proxy/rack_request'

I haven't tested it, but makes sense to me it'd work. Maybe just a readme update is in order.

wjordan commented 8 years ago

Note that in my tests I also needed to update the oauth gem to 0.5.x by relaxing the dependency constraint (see #90).

rivernate commented 7 years ago

closing this since the fix is to use a newer version of the oauth gem. The dependency on the oauth gem has been relaxed to allow this.

oleksandr-danylchenko commented 1 year ago

Updating the oauth to at least 0.5.1 and adding require 'oauth/request_proxy/action_controller_request' at the start of the file helped me to extend the list of available proxies to:

{
 Net::HTTPGenericRequest=>OAuth::RequestProxy::Net::HTTP::HTTPRequest, 
 Hash=>OAuth::RequestProxy::MockRequest, Rack::Request=>OAuth::RequestProxy::RackRequest,
 ActionDispatch::Request=>OAuth::RequestProxy::ActionControllerRequest
}