Skip to content

Instantly share code, notes, and snippets.

@wtrocki
Created January 24, 2019 13:08
Show Gist options
  • Select an option

  • Save wtrocki/99244f15408b62d46b76c85b94ad4859 to your computer and use it in GitHub Desktop.

Select an option

Save wtrocki/99244f15408b62d46b76c85b94ad4859 to your computer and use it in GitHub Desktop.
public getHeaderProvider(tokenUpdateTime: number) {
const headerProvider = () => {
const tokenUpdate = this.extract().updateToken(tokenUpdateTime) as any;
// Keycloak doesn't use a proper promise. Instead it uses success and error.
return new Promise((resolve, reject) => {
tokenUpdate.success(() => {
resolve({ "Authorization": "Bearer " + this.extract().token });
}).error((error: any) => {
// tslint:disable-next-line:no-console
console.info("Cannot update keycloak token", error);
reject(error);
});
});
};
return headerProvider;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment