How to use devise gem for authentication in API-only Rails application

Viewed 24406

I want to create a rails API with the devise gem for authentication. I am using Chrome Postman to check API outputs.

My environments:

  • Rails 4.2
  • Ruby 2.3

What I did:

  1. ran

    rails new my_api
    cd my_api
    
  2. added devise gem in Gemfile

  3. bundle install
  4. added

    config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
    

    to environment/development.rb

  5. created one user using rails console

After that I tried to login from postman. I gave email and password into headers of postman.

POST  http://localhost:3000/users/sign_in

headers

email abcd@gamilcom

password abcd1234

but it's not authenticating. What do I need to do?

2 Answers
Related