algolia / algolia/algoliasearch-client-javascript

Ability to set callback that return fresh API Key

Open
#1,307 6 comments 1 reaction 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.