mcordell / grape_token_auth

Token auth for grape apps
MIT License
52 stars 19 forks source link

“error”: “404 API Version Not Found” #52

Open anbublacky opened 7 years ago

anbublacky commented 7 years ago

Hi,

I am facing the following error while integrating grape token auth with grape.

I have mounted the auth api and it is available in the routes, but when i access the specific endpoints it is not available it says “error”: “404 API Version Not Found”. i dont know whether it is problem with grape / gta / routes that i mentioned.

but other urls doesn't have any problem except for auth urls.

Detailed explanation can be found here http://stackoverflow.com/questions/40672072/grape-token-auth-error-404-api-version-not-found

bluegod commented 7 years ago

I had exactly the same problem while trying to setup grape_token_auth. I resolved it by doing the following:

namespace :auth do
  mount_registration(to: '/', for: :user)
  mount_sessions(to: '/', for: :user)
  mount_token_validation(to: '/', for: :user)
  mount_confirmation(to: '/ ', for: :user)
end

In this case, you can call v1/auth/sign_out for instance, and should work. Without the namespace, you would call the endpoints this way directly: v1/sign_out.

Not sure if intentional or if there was a change in the Grape API, but using the default config of to: '/auth' will change the root for the auth endpoints to /auth, meaning you will have to call endpoints like /auth/v1/sign_outand provide the version to Grape by other means so it does not complain about it.