{"action":"created","issue":{"url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/717","repository_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth","labels_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/717/labels{/name}","comments_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/717/comments","events_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/717/events","html_url":"https://github.com/lynndylanhurley/devise_token_auth/issues/717","id":173872301,"number":717,"title":"401 on sign_in","user":{"login":"tomascharad","id":1534092,"avatar_url":"https://avatars.githubusercontent.com/u/1534092?v=3","gravatar_id":"","url":"https://api.github.com/users/tomascharad","html_url":"https://github.com/tomascharad","followers_url":"https://api.github.com/users/tomascharad/followers","following_url":"https://api.github.com/users/tomascharad/following{/other_user}","gists_url":"https://api.github.com/users/tomascharad/gists{/gist_id}","starred_url":"https://api.github.com/users/tomascharad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomascharad/subscriptions","organizations_url":"https://api.github.com/users/tomascharad/orgs","repos_url":"https://api.github.com/users/tomascharad/repos","events_url":"https://api.github.com/users/tomascharad/events{/privacy}","received_events_url":"https://api.github.com/users/tomascharad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-29T21:04:29Z","updated_at":"2016-09-08T14:14:55Z","closed_at":null,"body":"Hi,\r\n\r\nIf i activate the user authentication on the application controller:\r\n\r\n```ruby\r\nclass ApplicationController < ActionController::Base\r\n  include DeviseTokenAuth::Concerns::SetUserByToken\r\n  # Prevent CSRF attacks by raising an exception.\r\n  # For APIs, you may want to use :null_session instead.\r\n  # protect_from_forgery with: :exception\r\n  protect_from_forgery with: :null_session\r\n  before_action :authenticate_api_v1_user!\r\nend\r\n```\r\n\r\nThen I cannot log in.\r\n\r\n```bash\r\nTomass-MBP-2:apple-traceability tomascharad$ curl -XPOST -H 'Content-Type: application/json' http://localhost:3000/api/v1/auth/sign_in -d '{\"email\": \"tomas.charad@gmail.com\", \"password\": \"tomascharad87\" }'\r\n{\"errors\":[\"Authorized users only.\"]}Tomass-MBP-2:apple-traceability tomascharad$ \r\n```\r\n\r\n if I take out the autheticate_api_v1_user, then I can.\r\n\r\n```bash\r\nTomass-MBP-2:apple-traceability tomascharad$ curl -XPOST -H 'Content-Type: application/json' http://localhost:3000/api/v1/auth/sign_in -d '{\"email\": \"tomas.charad@gmail.com\", \"password\": \"tomascharad87\" }'\r\n{\"data\":{\"id\":1,\"email\":\"tomas.charad@gmail.com\",\"provider\":\"email\",\"company_id\":1,\"uid\":\"tomas.charad@gmail.com\",\"name\":\"Tomás Charad\",\"nickname\":null,\"image\":null}}Tomass-MBP-2:apple-traceability tomascharad$ \r\n```"},"comment":{"url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/comments/245611122","html_url":"https://github.com/lynndylanhurley/devise_token_auth/issues/717#issuecomment-245611122","issue_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/717","id":245611122,"user":{"login":"Sciandra-Leva","id":16104054,"avatar_url":"https://avatars.githubusercontent.com/u/16104054?v=3","gravatar_id":"","url":"https://api.github.com/users/Sciandra-Leva","html_url":"https://github.com/Sciandra-Leva","followers_url":"https://api.github.com/users/Sciandra-Leva/followers","following_url":"https://api.github.com/users/Sciandra-Leva/following{/other_user}","gists_url":"https://api.github.com/users/Sciandra-Leva/gists{/gist_id}","starred_url":"https://api.github.com/users/Sciandra-Leva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sciandra-Leva/subscriptions","organizations_url":"https://api.github.com/users/Sciandra-Leva/orgs","repos_url":"https://api.github.com/users/Sciandra-Leva/repos","events_url":"https://api.github.com/users/Sciandra-Leva/events{/privacy}","received_events_url":"https://api.github.com/users/Sciandra-Leva/received_events","type":"User","site_admin":false},"created_at":"2016-09-08T14:14:55Z","updated_at":"2016-09-08T14:14:55Z","body":"Well that's expected, right?\r\n\r\nI mean, by writing `before_action :authenticate_api_v1_user!` in your ApplicationController you are saying that every method called will require an authenticated user to call it (meaning, you have to provide the auth [headers](https://github.com/lynndylanhurley/devise_token_auth#token-header-format)  for every call).\r\n\r\nThat said, you should use `before_action :authenticate_api_v1_user!` in all those Controllers which will have authenticated method (ex. a user ability to change its favorite car)."}}
{"actor":{"display_login":"Sciandra-Leva"}}