matik12/aurelia-oauth

Expose OAuth interceptor for use by custom httpclient

Closed this issue · 2 comments

I have been using an adaptation of the library at https://github.com/MrTeyn/aurelia-adal, which is an aurelia wrapper for the adal.js library provided by Microsoft, but I have been having problems with internet explorer. That library works with all browsers except for IE. Its AuthInterceptor is exposed so that it can be used by other httpclients.

I explored using your library, but it appears that the way you are configuring the oauth interceptor. I have implemented a custom http client that inherits from the aurelia fetch client. There, I hook in the auth interceptor and then hook in my own interceptor afterward that.

How much effort would it be to make the OAuth interceptor available so that it can be used by a custom httpclient?

@ajdisalvo72 To expose interceptor is very easy, in the aurelia-oauth.ts file simply add OAuthInterceptor to the export statement at the end using comma separator. This should already work in runtime when you import it in the code. In case of Typescript, you need to add to the aurelia-oauth.d.ts file proper class export for OAuthInterceptor with implemented methods signatures, so then you can easily import it. The default plugin export is the configure function and other exports should work as well.

Please see my comment in the #11

@ajdisalvo72 after this commit 5e8a9cf OAuthInterceptor class should be exposed as plugin module export. Now you can simply import it to configure your custom http client as follows:

// import only interceptor
import { OAuthInterceptor } from 'aurelia-oauth';

// explicit import with all exports
import { OAuthService, OAuthTokenService, OAuthInterceptor } from 'aurelia-oauth';