Skip to content

Parse query request interceptor #1449

Open
@stephannielsen

Description

@stephannielsen

New Feature / Enhancement Checklist

Current Limitation

I am working on an app where we use an external authentication system based on JWT/Bearer access tokens. The solution is based on the feature added with this PR (parse-community/parse-server#6411) on server side. Now, we want to add our Bearer token to Parse query requests as described here: parse-community/docs#819.

However, apps typically renew such a bearer token quite often by using a refresh token flow etc. So we need to update the bearer token often. One solution for example would be to acquire a fresh Bearer token before every request (if needed) and then use the latest token on the request.

Feature / Enhancement Description

Pass one or many interceptor functions to Parse which are executed (in order) when a query is made. These interceptors can run asynchronous code.

Example Use Case

Append (dynamic) headers to network requests.

Alternatives / Workarounds

It is currently possible to pass custom headers via Parse.CoreManager to network requests, however these are static.
I found this issue asking for failure interceptors which are kind of similar: #19

However, the answer is quite presumptuous in my opinion. There are valid use cases for global interceptors and per request interceptors. Would be nice if the SDK provides mechanisms for both ways.

3rd Party References

Axios provides interceptors: https://axios-http.com/docs/interceptors
For native apps this is also often possible via the networking library, e.g. OkHttp for Android: https://square.github.io/okhttp/features/interceptors/

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions