我正在使用带有Angular 4应用程序的隐式流的Azure AD . 我的NG4应用程序使用PathLocationStrategy进行路由,以便它可以利用干净的URL . 我的AAD身份验证请求如下所示:
授权通过,我被重定向到http://localhost:4200/login#id_token=xxxxx,然后被重定向到http://localhost:4200/home#id_token=xxxxx
我的路线看起来像这样:
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{
path: '', component: BlankLayoutComponent,
children: [
{ path: 'login#id_token=:id_token', component: LoginComponent }
]
},
{
path: '', component: BasicLayoutComponent,
children: [
{ path: 'home', component: StarterViewComponent }
]
},
// Handle all other routes
{ path: '**', redirectTo: 'home' }
我似乎无法获得配置的路由,从网址中获取id_token,以便我可以使用它来授权其他请求 . 如何从重定向中恢复此id_token?
1 回答
在组件 StarterViewComponent 中,实现接口 OnInit 并在方法ngOnInit中写入它 .