vendredi 18 novembre 2016

Grape token auth "error": "404 API Version Not Found"

I am using rails application, setup grape, and trying to authenticate all the endpoints. So tried grape token auth http://ift.tt/2fBXMGu and setup as told in the github doc. These are my configurations.

initializers/gta.rb

GrapeTokenAuth.setup! do |config|
  config.mappings = { user: User }
  config.secret   = 'aaa'
end

For api this is the folder structure

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)

So my routes are like

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)

When i access /api/v1/statuses/public_timeline it says 401 unauthorized, so authenticate_user! method is working

But when i post to /auth/api/v1 i get the following error

{  
  "error": "404 API Version Not Found"
}

How do i check where the error is happening or how do i solve this?

Aucun commentaire:

Enregistrer un commentaire