matik12/aurelia-oauth

Support Fetch Client

Closed this issue · 2 comments

I had already raised an issue about making the Auth interceptor available for custom httpclients, not realizing that you are supporting the aurelia http client rather than the aurelia fetch client.

From reading the documentation, it sounds like there is a reason why you are not supporting the fetch client. Could you give any details as to why not? It feels like the core aurelia team is encouraging use of the fetch client..

@ajdisalvo72 Yes, currently http client is only supported. The decision was made, because some of the features are not yet supported in fetch i.e. request rejecting. In the oauth interceptor in case when the token has expired and the request is going to be created, then interceptor can simply abort the request and broadcast proper event, without call an api when we expect it fails.

I was thinking about other solutions that could work in both cases and http client and fetch. I like your idea about exposing interceptor to use it later on with fetch client, but I think you would need slightly different implementation i.e. omitting this abort feature or it could be removed from the existing interceptor.

Another thing, would be to check if existing implementation works for fetch as well, i.e. importing http-client as fetch and configuring an interceptor.

I really like the idea of going with fetch for the feature, but I could find time to provide proper improvements and implementation in code yet.
.

@ajdisalvo72 with this commit c69e0a0 I have implemented support for both fetch and http clients. I hope you like it and everything is working as expected :)