-
-
Save mikecabana/b152cedd7d3537819b824ff3108aa23a to your computer and use it in GitHub Desktop.
Oidc Client Authorization Service - Async HTTP Interceptors | Angular 6.x | rxjs 6.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { UserManager, User } from 'oidc-client'; | |
import { Observable, from } from 'rxjs'; | |
@Injectable({ | |
providedin: 'root' | |
}) | |
export class AuthService { | |
private userManager: UserManager; | |
constructor () { | |
this.userManager = new UserManager({ | |
// options | |
}); | |
} | |
getUser(): Observable<User> { | |
// change the promise retruned from this.userManager.getUser() into an observable and return it | |
return from(this.userManager.getUser()); | |
} | |
// TODO - perform other UserMananger tasks i.e. singinSilent, signinRedirect, or signoutRedirect. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment