Try adding the app to the 'Authentication Administrator" Azure AD role or "Privileged Authentication Administrator" and then try again.
Microsoft Graph, revoking user's sign in sessions, returns InvalidAuthenticationToken error
Angel Fontalvo Avila
25
Reputation points
I'm attempting to revoke a user's sign in sessions, however I keep receiving a 401 unauthorize error.
Here is my code snippet:
async revokeSignInSessions(targetUser, accessToken) {
const query = `/users/${targetUser.id}/revokeSignInSessions`;
await azure.graph.post(query, {
headers: {
'Authorization': 'Bearer ' + accessToken
}
});
return 'success';
}
I receive the following error:
error: {
code: 'InvalidAuthenticationToken',
message: 'Access token is empty.'
}
If I place a debugging stop point, I can see that the access token contains a token value.
The Microsoft Graph API App has been granted the following permissions:
Thank you in advance for your time and attention
2 answers
Sort by: Most helpful
-
-
Angel Fontalvo Avila 25 Reputation points
2023-09-06T16:07:24.51+00:00 The issue was due to the syntax of the post request. It apparently required a body, even if empty. After including an empty body in the request, I was able to perform the operation successfully.
await azure.graph.post(query, {}, { headers: { 'Authorization': 'Bearer ' + accessToken } });