2

I am building an API in ruby on rails. The API has a authentification system created with Devise. I wanted to test my API methods using postman with http request but everytime I try I get the following response :

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

How can I simulate a logged in user in my postman request to make my request work ? Or is there a better way to test my API ?

Taimoor Changaiz
  • 10,250
  • 4
  • 49
  • 53
David Geismar
  • 3,152
  • 6
  • 41
  • 80

1 Answers1

0

You need a token based authentication to properly authenticate an api with devise. Token authentication is no longer included in devise gem but there is another gem called devise_token_auth that uses devise for authenticating apis using tokens.

It sends authentication headers in the response headers after a successful first sign in using email and password, you have to use these headers for every other request that you send to the application to be properly auhenticated.

Optimus Pette
  • 3,250
  • 3
  • 29
  • 50
  • 1
    In that case, is there a way to force Postman to refresh token header for next request each time after a new one has come in previous response? – dhilt Oct 12 '17 at 15:03