Hello!
I'm using devise_token_auth to implement the authentication on my Rails API and I'm struggling to make it work with ESA.
When I make a POST to /auth/sign_in:
curl -XPOST -v -H 'Content-Type: application/json' localhost:3000/auth/sign_in -d '{"user": {"email": "[email protected]", "password": "secretpassword"}}'
I receive most of the data (such as the access-token and the client) in the response's header:
* Connected to localhost (::1) port 3000 (#0)
> POST /auth/sign_in HTTP/1.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 58
>
* upload completely sent off: 58 out of 58 bytes
< HTTP/1.1 200 OK
< access-token: token123
< token-type: Bearer
< client: client123
< expiry: 1234567890
< uid: [email protected]
< Content-Type: application/json; charset=utf-8
...
* Connection #0 to host localhost left intact
And some data in the response's body:
{"data":{"id":1,"email":"[email protected]","name":"Example User","provider":"email","uid":"[email protected]"}}
As you can see, the access-token, crucial to ESA, is in the headers. Is there a way I can handle data from these headers with ESA?
(Sorry if I'm being too dumb here.)
This is not the response that ESA expects. Instead it respects the token and user identification to be in the response body, e.g.
{ "token": "token", "email": "[email protected]" }
I see! I'll figure something out.
Thanks for the quick reply and for the awesome work on ESA.
hi @romulomachado
Do you figure it out? I encounter the same issue as yours.
Hey @cs0511!
I ended up not using devise_token_auth and going with a standard solution. I wrote about it on my blog.
Thank you @romulomachado
I saw this great blog, and followed these steps, that's awesome. But my only concern is everytime user login with the same token, do you think it is secure? And why do you think it is standard solution ?
I am still trying to use devise_token_auth , even if I don't know how many issues I need to fix to make it work. Could you kindly share your experience why you switched to the stand solution?
I am not sure if I need to discuss here or in your blog, please let me know.
Thank you again for your great blog.馃槃
Anyway, is there is a way to make ESA work with devise_token_auth?
Most helpful comment
Anyway, is there is a way to make ESA work with devise_token_auth?