-
Notifications
You must be signed in to change notification settings - Fork 117
Using feathers-authentication-client for an existing API? #478
Comments
What version of feathers-authentication is on the existing API? |
I'm sorry. We were using a Laravel API in a /authenticate route that
returns the token in the format of `{ token: '...' }`. Since it was
authenticating and the token was being returned, I thought the problem
was due to feathers-authentication on the client not knowing the key to
take. Is there a way to configure it as such?
…On 4/10/2017 9:16 PM, Marshall Thompson wrote:
What version of feathers-authentication is on the existing API?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#478 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AOoXKXkNgyWWql2tjQfNUNdAcPkFJ13Sks5ruiuegaJpZM4M4fZC>.
|
It's not configurable right now. Here's the line that needs to be modified: https://github.com/feathersjs/feathers-authentication-client/blob/master/src/passport.js#L235 |
So the whole { token: '...' } is stored because there's no |
We really ought to allow this to be customized. I created an issue for it here: feathersjs-ecosystem/authentication-client#38. I don't think it would be a difficult PR if you want to give it a shot. ;) |
Well, since you've brought it up, might as well try. :) |
Ok, going to close this in favour of tracking in the auth-client issue. |
@prime-ralph I also added a comment here: feathersjs-ecosystem/authentication-client#38 (comment) TL;DR could you not use a hook on the client to transform to and from the key name that you want? |
A question: from what I gather, you can only use hooks on services, but since I'm using the |
Try this: app.service('authentication').hooks(`...`) |
After tuning, here's what I ended up using, for those who end up with the same situation: api.service('authenticate').hooks({
after: {
all(hook) {
Object.assign(hook.result, { accessToken: `Bearer ${hook.result.token}` });
return Promise.resolve(hook);
},
},
}); The |
Steps to reproduce
Was doing this in a fresh project:
Actual behavior
Instead of the behavior outlined in the docs, this results in the following:
api.get('token')
returns undefined, and the localstorage token has a key of 'token', but with a value of[object Object]
.I suspect this is because I'm trying to authenticate with a different API server (a Laravel jwt-auth one instead of another Feathers server) which returns, upon authentication,
{ token: '...'}
.At the
console.log('Authenticated!', response, api.get('token'));
part, the response prints out while theapi.get()
call returns undefined. If I try another request in that promise chain, I can also see that the token isn't being included in subsequent call headers.System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working):
feathers@2.1.1
feathers-authentication-client@0.3.1
feathers-hooks@1.8.1
feathers-rest@1.7.1
NodeJS version:
v6.9.1
Operating System:
Windows 10
Browser Version:
Latest Chrome.
Module Loader:
Basic
react-boilerplate
stuff.webpack@2.2.0-rc.3
webpack-dev-middleware@1.9.0
webpack-hot-middleware@2.15.0
The text was updated successfully, but these errors were encountered: