Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doorkeeper password grant URI::InvalidURIError: query conflicts with opaque

Rails, Devise and Doorkeeper... Trying to test password grant and getting error: URI::InvalidURIError: query conflicts with opaque Any ideas?

Update: I created a second rails app that was able to get a token.. so maybe something about native_redirect_uri

Doorkeeper.configure do
  orm :active_record

  resource_owner_authenticator do
      # current_user || warden.authenticate!(:scope => :user)
  end

  resource_owner_from_credentials do |routes|
    user = User.find_for_database_authentication(email: params[:username])
    user if user && user.valid_password?(params[:password])
  end


  reuse_access_token

  use_refresh_token

  native_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'

  grant_flows %w(password)


  skip_authorization do |resource_owner, client|
    true
  end

end

Using oauth2 I create an application, give it a random name and for site uri: urn:ietf:wg:oauth:2.0:oob

Then using a user's credentials I run these commands:

client = OAuth2::Client.new('caa5ia541111698b34e66056e18b9afd6cb90c0d200d5dac99584da5a6b83b411', 'e45c78992a9eeb609b72cf5b56aea8dd999ec7dc9594a4211b8265f525a75870', :site => "urn:ietf:wg:oauth:2.0:oob")
access_token = client.password.get_token('[email protected]', 'realpassword')

I'm roughly following this example here

like image 302
esteban Avatar asked Mar 04 '16 19:03

esteban


1 Answers

I ran into this error myself and was very confused, as it is a pretty cryptic error concerning internals of the URI library. My problem was that the first string I was joining did not specify a protocol (https:// or http://). Adding one solved my problem!

like image 178
NealJMD Avatar answered Sep 22 '22 17:09

NealJMD