Curl Sign in doesn't output Auth_Token

70 views
Skip to first unread message

Cameron Barker

unread,
Jan 4, 2013, 9:15:11 PM1/4/13
to plataforma...@googlegroups.com
Hi all,

Really enjoy using Devise.  I'm building a iOS app with a rails backend with authentication powered by Devise.  When I push a curl sign-in request:

curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"user":{"login":"exa...@example.com","password":"secret"}}'  http://localhost:3000/users/sign_in.json -i

I get back an out put with all my user info but not the associated auth_token which I was hoping to store on the iOS phone for future requests.

{"bio":null,"birthday":null,"created_at":"2012-12-17T00:58:06Z","email":"exa...@example.com","full_name":null,"gender":null,"id":1,"phone_number":null,"profile_picture":null,"updated_at":"2013-01-05T01:50:55Z","username":"example","website":null}* Closing connection #0

I know that the user has a token as I see it in the rails c and have been using it to make requests while I develop.

Any help would be great!!!

Thank you!
Cameron

Lucas Mazza

unread,
Jan 5, 2013, 11:01:24 AM1/5/13
to plataforma...@googlegroups.com
By default Devise overrides the serializable_hash method to expose only accessible attributes (so things like the encrypted_password doesn't get serialized by default on APIs).

You could try to override this method and add the auth_token to the hash, something like this:

def serializable_hash(options = nil)
  super(options).merge("auth_token" => auth_token)
end

Cameron

--
 
 
 

Cameron Barker

unread,
Jan 5, 2013, 3:44:02 PM1/5/13
to plataforma...@googlegroups.com
Hi Lucas.

This worked perfectly!  Thank you

Cameron
Reply all
Reply to author
Forward
0 new messages