Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth Headers missing for protected routes #63

Open
Gooner91 opened this issue May 27, 2020 · 1 comment
Open

Auth Headers missing for protected routes #63

Gooner91 opened this issue May 27, 2020 · 1 comment

Comments

@Gooner91
Copy link

I am using "redux-token-auth": "^0.19.0" with devise_token_auth. I may be missing something but I think this is something faced by others as well (#28 and #34 for reference). #34 is almost the exact issue I am facing but there is no conclusion on that thread (whether this is expected behavior or if the library handles the auth headers between the requests).
I have been able to set up sign_in/sign_up/sign_out easily but when it comes to sending requests to protected routes on my API I end up with 401 response. The reason, auth headers are not added to the axios requests for those protected routes (routes wrapped up under before_action: authenticated_user! callback).
During initial debugging I used postman with headers extracted from my localstorage and request went fine. It is mentioned in #34 that this library handles addition of auth headers out of the box but I don't think that is the case or I may be missing something.
For now, after spending a lot of hours going through the docs, a few online examples (which only cover authentication and no subsequent request) and any related issues I am inclined to add the the headers as suggested in a few ways on #28. However, I still assume the library must have the functionality to handle this as well.
Furthermore, I request there should be some information about requests made by client to protected resources in the docs.

@dlikhten
Copy link

I have been using

import axios from 'redux-token-auth/node_modules/axios';

...

axios.defaults.headers.common

This lets me get the redux-token-auth axios headers and do what I want with them. This library needs a major refactor so it isn't relying on axios, in such an integrated way, or at least let you pass in an axios instance, but currently there is no development going on there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants