algolia / algolia/algoliasearch-client-javascript
Ability to set callback that return fresh API Key
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 226
- PR merge metrics
- No merged PRs in 30d
Description
**Context :**
Following the issue #772, we can now check remaining validity of API Key.
**Problem :**
In our application, we are generating very short term API Keys (5 minutes) to always be compliant with filters and visibility that are set in the Key (from our backend according to user access rights).
It could be very cool to add a callback while creating the `searchclient` which will be called when API Key is near expiration and which should return a fresh API Key.
**Workaround :**
Currently, we are wrapping the search methods from `searchclient` into some of our wrappers that do the check before every request.
If we detect that API Key is expired, we generate a new `searchclient` with the updated API Key and use it to execute the query.
However there is two bad concerns about this workaround :
1. As searchclient instance change, the `InstantSearch` node seems to detect it and relaunch a new query (which is now duplicated).
2. As searchclient instance change, what happen to the currently built query cache ? Reset ?
Yours faithfully,
LCDP
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.