-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add header on refresh #13
Comments
I found a workaround: I have subclassed the class MyHttp extends JwtHttp {
request(urlOrRequest: string | Request, options: RequestOptionsArgs = {}) {
// Here is where I modify the headers, before calling `super()`
return super.request(urlOrRequest, options);
}
} It's not an ideal solution, because it affects all HTTP requests. In my use case, that is what I need, but it would be useful to be able to configure the refresh token HTTP request. Any suggestions @leonardobazico? |
Scratch that. I've just discovered that the above method does not work: when the HTTP request is made to refresh the token, the So I'm currently at a dead end... @leonardobazico if you've got a moment to have a look, it would be much appreciated. :-) |
Ok, so here's one solution to the original problem I described: override the export class MyHttp extends JwtHttp {
constructor(
refreshConfigService: JwtConfigService,
http: Http,
defOpts?: RequestOptions,
) {
super(refreshConfigService, http, defOpts);
}
protected _refreshTheToken() {
// keep a copy of current headers by cloning them
const savedGlobalHeaders: Array<Object> = this._config.globalHeaders.slice(0);
// and then add the headers I want here
this._config.globalHeaders.push('header-name', 'header-value');
return super._refreshTheToken().do(() => {
// restore the headers we saved
this._config.globalHeaders = savedGlobalHeaders;
});
}
} It's a bit messy, but it does the job. @leonardobazico, what do you think? |
Hi
I'd like to be able to add a header on every refresh. The value of the header will be calculated (and unique) every time the refresh endpoint is hit.
I can't see how to do this currently... can anyone help?
many thanks
Matt
The text was updated successfully, but these errors were encountered: