Skip to content

Instantly share code, notes, and snippets.

@danielcrisp
Created July 25, 2017 13:23
Show Gist options
  • Save danielcrisp/e2f4f817f34c1f6621d29b3d575f2d1d to your computer and use it in GitHub Desktop.
Save danielcrisp/e2f4f817f34c1f6621d29b3d575f2d1d to your computer and use it in GitHub Desktop.
AuthService - Async HTTP Interceptors with Angular 4
import { Injectable } from '@angular/core';
import { UserManager, User } from 'oidc-client';
@Injectable()
export class AuthService {
private userManager: UserManager;
constructor () {
this.userManager = new UserManager({
// options
});
}
getUser (): Promise<User> {
return this.userManager.getUser(); // <-- returns a Promise
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment