0
votes

I have a controller named topics. When I visit the page that should be authenticated by devise gem. But, using POSTMAN for testing JSON requests, shows a error like this..

{
"error": "You need to sign in or sign up before continuing."
}

This causes due to the devise authentication. In order to avoid this issue, I simply put as a

skip_before_action:authenticate_user!

In my opinion this ignores the authentication. If there is any way to use devise normal authentication for HTML request and API basic authentication for JSON requests?

1

1 Answers

1
votes

You can use the code from the Devise documentation.

However, in my opinion, it is better to have separate controllers for users and API. Then, use Devise for users and any other authentication mechanism for the API requests.