I have created an Angular application where I have to use Azure DevOps REST API to retrieve ticket details. I'm authenticating user against clients Azure-AD using @azure/msal-angular", "@azure/msal-browser"
packages.
I'm using this document which says this the syntax for the URL should be something like GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}
which did not work for me
But when I paste GET https://[ClientURL.com]/[resource/location]/_apis/wit/workitems?ids=123
into browser address bar I get JSON response.
I'm using the token I get to consume REST services by calling my clients url something like this
GET https://[ClientURL.com]/[resource/location]/_apis/wit/workitems?ids=123
I'm intercepting the requests using MsalInterceptor
which will add the Authentication header.
I get an error saying Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.
I couldn't find any good enough documents for angular and having trouble understanding whether I have to authenticate again for REST API's or the AD authentication should just be fine.
UPDATE
The application was already built using C#. My client wants it to be developed using Angular. This is my login configuration
export function MSALInstanceFactory(): IPublicClientApplication {
return new PublicClientApplication({
auth: {
clientId: '' // my registered angular app clientId,
authority: 'https://login.microsoftonline.com/my_tenentid',
redirectUri: 'https://localhost:8080',
},
cache: {
cacheLocation: 'localStorage'
}
})
}
I'm using MSAL to authenticate my app
loginMsal() {
this.msalService.loginPopup().subscribe(
(response: AuthenticationResult) => {
this.loginSuccessfull(response)
})
}
Need help!