AADSTS65001 Failed to acquire token silentely when trying to get Azure Devops scopes access
I have a JS Application that is an SPA registred in azure with the following authorized APIs
As you can see, none of them require Administrator consent.
When calling for silent token, I am using the following
export const apiRequest = {
scopes: [
'user_impersonation',
'vso.tokenadministration',
'vso.tokens',
'vso.work',
'vso.work_full',
'User.Read',
'User.ReadBasic.All'
],
forceRefresh: false
};
# Component :
...
const { instance } = useMsal();
useEffect(() => {
const fetchToken = async () => {
try {
const response = await instance.acquireTokenSilent(apiRequest);
setAccessToken(response.accessToken);
} catch (error) {
console.error('Failed to acquire token silently', error);
}
};
fetchToken();
}, [instance]);
...
I use the following react libraries and versions :
"@azure/msal-browser": "^3.11.1",
"@azure/msal-react": "^2.0.14"
Login works well and redirects me into my application, but when I am trying to fetchToken to call for Azure Devops, I end up with the following error :
Failed to acquire token silently InteractionRequiredAuthError: invalid_grant: AADSTS65001: The user or administrator has not consented to use the application with ID '[id]' named '[name]'. Send an interactive authorization request for this user and resource. Trace ID: [traceId] Correlation ID: [CorrelationId] ...
For obvious reasons, I don't want to ask or be granted unnecessary administrator consent to my application if it is not required which I get no indication that it is, what could I do to understand where is something wrong ? Thanks in advance