我使用Rails应用程序,设置葡萄,并试图所有端点进行身份验证。所以尝试葡萄代币验证https://github.com/mcordell/grape_token_auth和安装在github文档中告诉。这些是我的配置。葡萄令牌身份验证“错误”:“404 API版本未找到”
初始化/ gta.rb
GrapeTokenAuth.setup! do |config|
config.mappings = { user: User }
config.secret = 'aaa'
end
对于API,这是文件夹结构
app/api/tmo/api.rb -> mounted two version root file
app/api/tmo/vl/root.rb -> mounted all the other files for v1
app/api/tmo/vl/restaurants.rb -> here lies the mount authentication
include GrapeTokenAuth::MountHelpers
include GrapeTokenAuth::TokenAuthentication
mount_registration(to: '/auth', for: :user)
mount_sessions(to: '/auth', for: :user)
mount_token_validation(to: '/auth', for: :user)
mount_confirmation(to: '/auth', for: :user)
所以我的路线是一样
Running via Spring preloader in process 9309
POST /auth/api/v1(/.:format)
DELETE /auth/api/v1(/.:format)
PUT /auth/api/v1(/.:format)
POST /auth/api/v1/sign_in(.:format)
DELETE /auth/api/v1/sign_out(.:format)
GET /auth/api/v1/validate_token(.:format)
GET /auth/confirmation/api/v1(/.:format)
GET /api/v1/statuses/public_timeline(.:format)
当我访问/ API/V1 /状态/ public_timeline它说401未经授权,所以authenticate_user!方法工作
但是当我发布到/认证/ API/V1,我收到以下错误
{
"error": "404 API Version Not Found"
}
如何检查其中的错误正在发生或我怎么解决这个问题?