brbernardo90

Joined

50 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Doorkeeper and Authorization Code Flow

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

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.