没有路由匹配 [GET]“/oauth/applications”
No route matches [GET] "/oauth/applications"
当我试图去 /oauth/applications
我得到了 404
我看不到路线:
rails routes | grep oauth
我想要一个 200 并访问该页面。
我的配置:
# frozen_string_literal: true
Doorkeeper.configure do
# Change the ORM that doorkeeper will use (needs plugins)
orm :active_record
# This block will be called to check whether the resource owner is authenticated or not.
resource_owner_authenticator do
User.find_by(id: session[:current_user_id]) || redirect_to(new_user_session_url)
end
# In this flow, a token is requested in exchange for the resource owner credentials (username and password)
resource_owner_from_credentials do |_routes|
user = User.where(login: params[:username]).first
if user.valid_password?(params[:password])
user
end
end
# Access token expiration time (default 2 hours).
# If you want to disable expiration, set this to nil.
access_token_expires_in 1.day
# implicit and password grant flows have risks that you should understand
# before enabling:
# http://tools.ietf.org/html/rfc6819#section-4.4.2
# http://tools.ietf.org/html/rfc6819#section-4.4.3
#
grant_flows %w(password authorization_code client_credentials)
# grant_flows %w[password]
# Under some circumstances you might want to have applications auto-approved,
# so that the user skips the authorization step.
# For example if dealing with a trusted application.
# skip_authorization do |resource_owner, client|
# client.superapp? or resource_owner.admin?
# end
skip_authorization do
true
end
admin_authenticator do |routes|
User.find_by(id: session[:admin_id], roles: '{100}') || redirect_to(routes.new_user_session_url)
end
# default_scopes :read, :write
# optional_scopes :create, :update
# WWW-Authenticate Realm (default "Doorkeeper").
# realm "Doorkeeper"
end
在我的 router.rb 文件中:
use_doorkeeper do
# No need to register client application
skip_controllers :applications, :authorized_applications
end
请在您的 route.rb 文件中添加以下行
Rails.application.routes.draw do
use_doorkeeper
# your routes
end
而不是
use_doorkeeper do
# No need to register client application
skip_controllers :applications, :authorized_applications
end
我用过:
use_doorkeeper
我正在跳过应用程序控制器
您是否将 use_doorkeeper
添加到您的 routes.rb
?它必须看起来像:
Rails.application.routes.draw do
use_doorkeeper
# your routes
end
这将挂载以下路线:
GET /oauth/authorize/native?code
GET /oauth/authorize
POST /oauth/authorize
DELETE /oauth/authorize
POST /oauth/token
POST /oauth/revoke
POST /oauth/introspect
resources /oauth/applications
GET /oauth/authorized_applications
DELETE /oauth/authorized_applications/:id
GET /oauth/token/info
您可以在此处找到有关路由配置的其他详细信息:https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes
您可以在 official README or in the Wiki 中找到更多信息(在这里您还可以找到一些关于如何安装和配置 Doorkeeper gem 的外部文章)。
当我试图去 /oauth/applications
我得到了 404
我看不到路线:
rails routes | grep oauth
我想要一个 200 并访问该页面。
我的配置:
# frozen_string_literal: true
Doorkeeper.configure do
# Change the ORM that doorkeeper will use (needs plugins)
orm :active_record
# This block will be called to check whether the resource owner is authenticated or not.
resource_owner_authenticator do
User.find_by(id: session[:current_user_id]) || redirect_to(new_user_session_url)
end
# In this flow, a token is requested in exchange for the resource owner credentials (username and password)
resource_owner_from_credentials do |_routes|
user = User.where(login: params[:username]).first
if user.valid_password?(params[:password])
user
end
end
# Access token expiration time (default 2 hours).
# If you want to disable expiration, set this to nil.
access_token_expires_in 1.day
# implicit and password grant flows have risks that you should understand
# before enabling:
# http://tools.ietf.org/html/rfc6819#section-4.4.2
# http://tools.ietf.org/html/rfc6819#section-4.4.3
#
grant_flows %w(password authorization_code client_credentials)
# grant_flows %w[password]
# Under some circumstances you might want to have applications auto-approved,
# so that the user skips the authorization step.
# For example if dealing with a trusted application.
# skip_authorization do |resource_owner, client|
# client.superapp? or resource_owner.admin?
# end
skip_authorization do
true
end
admin_authenticator do |routes|
User.find_by(id: session[:admin_id], roles: '{100}') || redirect_to(routes.new_user_session_url)
end
# default_scopes :read, :write
# optional_scopes :create, :update
# WWW-Authenticate Realm (default "Doorkeeper").
# realm "Doorkeeper"
end
在我的 router.rb 文件中:
use_doorkeeper do
# No need to register client application
skip_controllers :applications, :authorized_applications
end
请在您的 route.rb 文件中添加以下行
Rails.application.routes.draw do
use_doorkeeper
# your routes
end
而不是
use_doorkeeper do
# No need to register client application
skip_controllers :applications, :authorized_applications
end
我用过:
use_doorkeeper
我正在跳过应用程序控制器
您是否将 use_doorkeeper
添加到您的 routes.rb
?它必须看起来像:
Rails.application.routes.draw do
use_doorkeeper
# your routes
end
这将挂载以下路线:
GET /oauth/authorize/native?code
GET /oauth/authorize
POST /oauth/authorize
DELETE /oauth/authorize
POST /oauth/token
POST /oauth/revoke
POST /oauth/introspect
resources /oauth/applications
GET /oauth/authorized_applications
DELETE /oauth/authorized_applications/:id
GET /oauth/token/info
您可以在此处找到有关路由配置的其他详细信息:https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes
您可以在 official README or in the Wiki 中找到更多信息(在这里您还可以找到一些关于如何安装和配置 Doorkeeper gem 的外部文章)。