-
Hello community, I was hoping to lobby your assistance. I would like to dynamically set the access token while using the feathers socketio or rest client for get, find, remove, create and update requests. After initial login, I would like the ability to change the auth token dynamically. An example would be below. Any help would be greatly appreciated.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yes, you can do this dynamically by setting const setAuthentication = context => {
const { accessToken, ...query } = context.params.query;
context.params.authentication = {
strategy: 'jwt',
accessToken
}
// For subsequent requests, use the query without `accessToken`
context.params = {
...context.params,
query
}
} Then on the client you can do: const results = await app.service("messages").find({
query: {
...query,
accessToken
}
}); Keep in mind that Socket.io connections will still maintain a connection for the user that originally authenticated (if any). |
Beta Was this translation helpful? Give feedback.
Yes, you can do this dynamically by setting
params.authentication
before theauthenticate('jwt')
hook. In your case you would pull the access token from the query in a hook:Then on the client you can do:
Keep in mind that Socket.io connections will still maintain a connection for the user tha…