import { Component , OnInit } from '@angular/core' ; import { OktaAuthStateService } from '@okta/okta-angular' ; import { OktaAuth } from '@okta/okta-auth-js' ; interface ResourceServerExample { label : string ; url : string ; } @ Component ( { selector : 'app-home' , templateUrl : './home.component.html' , styleUrls : [ './home.component.css' ] } ) export class HomeComponent implements OnInit { resourceServerExamples : Array < ResourceServerExample > ; userName : string = '' ; constructor ( public authStateService , private oktaAuth ) { this . resourceServerExamples = [ { label : 'Node/Express Resource Server Example' , url : 'https://github.com/okta/samples-nodejs-express-4/tree/master/resource-server' , } , { label : 'Java/Spring MVC Resource Server Example' , url : 'https://github.com/okta/samples-java-spring-mvc/tree/master/resource-server' , } , ] ; } async ngOnInit ( ) { const isAuthenticated = await this . oktaAuth . isAuthenticated ( ) ; if ( isAuthenticated ) { const userClaims = await this . oktaAuth . getUser ( ) ; this . userName = userClaims . name as string ; } } }