Currently, I am in the process of developing a web application using Rails as the backend API and Vue.js as the frontend library. For authentication purposes, I have integrated the devise_token_auth library. However, I am facing difficulty in retrieving the token information sent inside the header of the response when working with JavaScript.
I discovered alternative libraries such as J-toker, ng-token-auth, angular2-token, etc. After looking into them, I decided to follow jtoker auth because I specifically wanted to integrate it with vue.js. However, I soon realized that it requires React components which was not ideal for my project. Below is a sample response obtained using Postman:
Response Body :
{"data":{"id":3,"email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d2b1bdbca6b3b1a692b6b3a8a8beb7b0bba0b6a1fcb1bdbf">[email protected]</a>","provider":"email","uid":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3a5955544e5b594e7a5e5b4040565f5853485e4914595557">[email protected]</a>","name":null,"image":null}}
Response Header :
Cache-Control →max-age=0, private, must-revalidate
Content-Type →application/json; charset=utf-8
ETag →W/"2af9684eadab13f0efebb27b8e29a7be"
Transfer-Encoding →chunked
Vary →Origin
X-Content-Type-Options →nosniff
X-Frame-Options →SAMEORIGIN
X-Request-Id →41f3df67-574c-4095-b471-a8fd08b85be5
X-Runtime →0.768768
X-XSS-Protection →1; mode=block
access-token →DGoclk9sbb_LRgQrr5akUw
client →7_Lfy0RlEbzkpLOpiQCKRQ
expiry →1516322382
token-type →Bearer
uid →<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="93f0fcfde7f2f0e7d3f7f2e9e9fff6f1fae1f7e0bdf0fcfe">[email protected]</a>