angular - 使用 MSAL-Angular 对 Azure DevOps 服务进行身份验证
问题描述
我尝试将我的应用程序配置为通过 oauth 连接到 Azure DevOps Services。我的应用程序在 Angular 中,我想我可以使用 MSAL-Angular 。
但是示例配置设置了 protectedResourceMap.set('https://graph.microsoft.com/v1.0/me', ['user.read']); 我喜欢使用范围 vso.project vso.work_full 配置到 Azure DevOps 服务
我很好地创建了应用程序,并通过邮递员模拟获取令牌并使用。但在我的应用程序中,MSAL 不起作用。
我试过了 :
export function MSALInterceptorConfigFactory(): MsalInterceptorConfiguration {
const protectedResourceMap = new Map<string, Array<string>>();
protectedResourceMap.set('https://graph.microsoft.com/v1.0/me', ['user.read', 'vso.project', 'vso.work_full']);
return {
interactionType: InteractionType.Redirect,
protectedResourceMap
};
}
export function MSALGuardConfigFactory(): MsalGuardConfiguration {
return {
interactionType: InteractionType.Redirect,
authRequest: {
scopes: ['user.read', 'vso.project', 'vso.work_full']
},
loginFailedRoute: '/login-failed'
};
}
@NgModule({
declarations: [
AppComponent,
HomeComponent,
ProfileComponent,
DetailComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
MatButtonModule,
MatToolbarModule,
MatListModule,
HttpClientModule,
MsalModule
],
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: MsalInterceptor,
multi: true
},
{
provide: MSAL_INSTANCE,
useFactory: MSALInstanceFactory
},
{
provide: MSAL_GUARD_CONFIG,
useFactory: MSALGuardConfigFactory
},
{
provide: MSAL_INTERCEPTOR_CONFIG,
useFactory: MSALInterceptorConfigFactory
},
MsalService,
MsalGuard,
MsalBroadcastService
],
bootstrap: [AppComponent, MsalRedirectComponent]
})
export class AppModule { }
但是 MSAL 没有在应用程序中连接。
我喜欢用https://app.vsaex.visualstudio.com/me代替https://graph.microsoft.com/v1.0/me
解决方案
推荐阅读
- ios - Swift 表格视图返回我的字典的一些单元格
- javascript - 在这种情况下如何使用 JavaScript 句例?
- android - 在三星 Galaxy M20 中反应原生应用程序白屏
- kotlin - 从在 Kotlin 中存储为文本的日历时间中减去天数
- c++ - macOS 上奇怪的 GDB 行为
- angular - 自定义范围滑块
- javascript - 使用 Accordion 布局反应路由器转换
- c - 数组[a,b]的c语法和行为
- codeigniter - 我可以使用 Codeigniter 验证规则将空字符串转换为 NULL 吗?
- python - 使用 Postgres 优化 Django 查询集查询