-
Notifications
You must be signed in to change notification settings - Fork 23
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
Make authenticated API calls #46
Comments
I just double checked my project(s) and I am using https://docs.feathersjs.com/api/authentication/client.html My app looks like:
In my oauth callback page I end up calling:
at this point the client will exchange the cookie for an auth token and stuff it in local storge. After this all subsequent calls should be authenticated. |
Hey @chris-garrett, I'm a beginner and I'm trying to implement this for the past 6 hours or so, I am having difficulties because app.authenticate() is a promise and not sure how to wait it out.
But it does not seem to work, can you give me some advice? :) |
First you can look at eddyystop/feathers-reduxify-authentication. Its a wrapper over app.authenticate() while maintaining an 'authorized' prop in the state. Your client will have to be in a 'waiting for auth' state until the promise resolves using app.authenticate() or until the authication state is set using feathers-reduxify-authentication. That can be awkward. You can look at (the by now quite outdated) You can always use a pollyfill for |
Steps to reproduce
After authentication, I store the accessToken in my redux state (and after that redux-persist automatically stores it in localStorage).
What I want to achieve is: Make every feathers API call with the accessToken, if it's present in the redux state.
What I'm doing now:
So what I'm doing is, before each API request, retrieve the accessToken from the localStorage (and not from the in-memory store!).
Expected behavior
There should surely be a way to do this without retrieving localStorage and parsing JSON before each api request.
Actual behavior
Didn't find a clean way to pass state variables to the feathers app.
The only way I found is, on every api request, do
But doing this on every method is not viable.
System configuration
Tell us about the applicable parts of your setup.
Module versions 2.1.0
NodeJS version: Not relevant
Operating System: Not relevant
Browser Version: Not relevant
React Native Version: Not relevant
Module Loader: Not relevant
The text was updated successfully, but these errors were encountered: