I am using the grape_rails gem to manage the APIs and on my endpoints I have the following:
..api/v4/endpoints/base.rb
class Endpoints::V4::Base < Endpoints::Base
before { authenticate_with_token! }
version 'v4', using: :path
mount Endpoints::V4::Menu
mount Endpoints::V4::Customer
mount Endpoints::V4::Orders
end
I would like to skip the authenticate_with_token! method to Endpoints::V4::Menu in my base.rb file, but it's not working for me.
I have already tried with:
class Endpoints::V4::Base < Endpoints::Base
skip_before { authenticate_with_token! only: :customer } # first test
before { authenticate_with_token! except: :customer } # second test
...
def customer
mount Endpoints::V4::Products
end
end
Thanks for your time
You can early return from your authentication method, only authenticate if some conditions are true.
or call the authentication method based on some condition