Ask A Question

Notifications

You’re not receiving notifications from this thread.

Doorkeeper and Authorization Code Flow

brbernardo90 asked in Gems / Libraries

Hi! I'm learning rails building an CRUD app with authorization. I want to autorizate http requests.

I can't generate the authoriation code, when send the url with client_id and callback url, the page is redirect to the root of my application. The same behavior happens when I click in the button "authorizate" in the application painel (see the image).

Codes:

doorkeeper.rb

Doorkeeper.configure do
  orm :active_record

  resource_owner_authenticator do
      User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
  end

  admin_authenticator do
     if current_user
       current_user
     else
       session[:user_return_to] = request.fullpath
       redirect_to(new_user_session_url)
     end
  end

  native_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
  grant_flows %w[authorization_code client_credentials]
end

routes.rb

Rails.application.routes.draw do
  use_doorkeeper
  devise_for :users
  resources :eventos
  get 'admin/index'
  root 'eventos#index'
  mount API::Base, at: "/"
end

application painel

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.