Question

I'm trying to use doorkeeper (https://github.com/applicake/doorkeeper/) to set up a simple OAuth provider, but having severe problems with renaming my routes.

I'm trying to set up my base doorkeeper route as '/oauth2/v1' instead of the '/oauth' route that comes pre-rolled.

Reading the wiki (https://github.com/applicake/doorkeeper/wiki/Customizing-routes) it seems that all I should need to do is modify

Rails.application.routes.draw do
  use_doorkeeper
end

to

Rails.application.routes.draw do
  use_doorkeeper :scope => 'oauth2/v1'
end

or perhaps namespace use_doorkeeper to 'oauth2' then provide a scope of 'v1'. Unfortunately nothing works. I can't get doorkeeper to use any other scope at all.

The wiki itself seems to be quite out of date, as Rails no longer uses that kind of construct in routes.rb, so the code I'm actually trying to change looks more like this:

DoorkeeperProvider::Application.routes.draw do
  scope 'oauth2' do
    use_doorkeeper :scope => 'v1'
  end
  ...
end

but again, nothing seems to be able to change the scope.

This is the output of rake routes:

      oauth_authorization GET    /oauth2/oauth/authorize(.:format)                   {:action=>"new", :controller=>"doorkeeper/authorizations"}
      oauth_authorization POST   /oauth2/oauth/authorize(.:format)                   {:action=>"create", :controller=>"doorkeeper/authorizations"}
      oauth_authorization DELETE /oauth2/oauth/authorize(.:format)                   {:action=>"destroy", :controller=>"doorkeeper/authorizations"}
              oauth_token POST   /oauth2/oauth/token(.:format)                       {:action=>"create", :controller=>"doorkeeper/tokens"}
       oauth_applications GET    /oauth2/oauth/applications(.:format)                {:action=>"index", :controller=>"doorkeeper/applications"}
                          POST   /oauth2/oauth/applications(.:format)                {:action=>"create", :controller=>"doorkeeper/applications"}
    new_oauth_application GET    /oauth2/oauth/applications/new(.:format)            {:action=>"new", :controller=>"doorkeeper/applications"}
       edit_oauth_application GET    /oauth2/oauth/applications/:id/edit(.:format)       {:action=>"edit", :controller=>"doorkeeper/applications"}
        oauth_application GET    /oauth2/oauth/applications/:id(.:format)            {:action=>"show", :controller=>"doorkeeper/applications"}
                          PUT    /oauth2/oauth/applications/:id(.:format)            {:action=>"update", :controller=>"doorkeeper/applications"}
                          DELETE /oauth2/oauth/applications/:id(.:format)            {:action=>"destroy", :controller=>"doorkeeper/applications"}
oauth_authorized_applications GET    /oauth2/oauth/authorized_applications(.:format)     {:action=>"index", :controller=>"doorkeeper/authorized_applications"}
 oauth_authorized_application DELETE /oauth2/oauth/authorized_applications/:id(.:format) {:action=>"destroy", :controller=>"doorkeeper/authorized_applications"}
         oauth_token_info GET    /oauth2/oauth/token/info(.:format)                  {:action=>"show", :controller=>"doorkeeper/token_info"}

It looks as if the :scope param to use_doorkeeper is just being ignored.

Any hints at this point would be very much appreciated.

Was it helpful?

Solution

So it looks like you're running into a recently fixed issue. See the commit here - https://github.com/applicake/doorkeeper/commit/a12f9eacaa9714a0681b42f0685e491e296d6560

What version are you running? In theory this should be fixed in 0.7.3.

I'd try using the master branch of doorkeeper from applicake/doorkeeper on Github. That should resolve this issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top