Forum Discussion
How do I sign out of my OIDC Entra ID Application?
We have an application protected with Entra ID using ODIC. To sign into our application or SPA goes through a series of redirects before getting a JWT and refresh token at the end of the Entra ID OIDC authentication flow. All of that works great.
When a user is done with our application, we want them to be able to sign out of our application. In our mind, that means invalidating the `refresh_token` they received when signing in. We're not seeing an OAuth endpoint to do that. Given the default lifetime for the refresh_token, I'd rather not simply ignore/discard it as it could be used to generate a new JWT (however unlikely).
I am posting this on here after searching the web for several hours. All I am able to find on the web is single sign-out (SLO), which would sign my user out of all of Office 365 when they sign out of our application. That is not what I want.
How do I invalidate the user's `refresh_token`? Is there a "revoke" endpoint in Entra ID? If not, then what other options do we have?
2 Replies
- AmezingtechsataraIron Contributor
To answer your actual question first: no, there isn't a revoke endpoint in Entra ID for one refresh token, or for one application. That's the thing the reply above glosses over, and it matters, because the Graph calls it suggests do something much bigger than signing the user out of your app.
Revoke-MgUserSignInSession and the invalidateAllRefreshTokens endpoint both invalidate all the refresh tokens issued to applications for that user — every app they've consented to, not just yours — plus the session cookies in their browser. Microsoft's own description of the operation is that the user has to sign in again to all applications they consented to. So it's a security action for a lost or stolen device, not a routine sign-out button, and it also needs the User.RevokeSessions.All permission, so your SPA can't just call it on its own behalf.
So for a normal sign-out you're choosing between three things, and none of them is 'invalidate just my app's refresh token':
Sign out locally only: delete the tokens your app holds and clear your own session, and don't touch Entra at all. The refresh token technically stays valid until it expires or is revoked, but your app no longer has a copy of it, so it can't be used — this is the standard SPA pattern, and it's what most apps mean by sign out.
End the shared session: send the user to Entra's logout endpoint with a post_logout_redirect_uri back to your app. That clears the Entra session cookie, which is also why it signs them out of other Microsoft apps in that browser — it's the one you said you don't want, and you're right to avoid it for a routine sign-out.
Revoke everything: the Graph call above, when you actually need the tokens dead — a compromised device, a user leaving. Expect a few minutes' delay before the revocation takes effect.
If you go with the local option, one thing worth doing is registering a front-channel logout URL on the app registration, so Entra can tell your app when the user signs out elsewhere and your app can drop its own session to match.
May consider on below:
- Use Microsoft Graph API
You can revoke a user's refresh tokens using the Microsoft Graph PowerShell SDK or REST API:Revoke-MgUserSignInSession -UserId <user-object-id>
This command invalidates all refresh tokens for the user, effectively signing them out of your app without triggering global SLO.
- Use invalidateAllRefreshTokens endpoint
If you're automating this via backend logic, you can call the Microsoft Graph endpoint:POST https://graph.microsoft.com/v1.0/users/{id}/invalidateAllRefreshTokens
This revokes all refresh tokens and forces reauthentication across apps using Entra ID.
- Use Microsoft Graph API