# Listen to revoked User API Key via MessageBus?

**URL:** https://meta.discourse.org/t/listen-to-revoked-user-api-key-via-messagebus/304479
**Category:** Development
**Tags:** rest-api
**Created:** [April 18, 2024, 3:15pm UTC](https://meta.discourse.org/t/listen-to-revoked-user-api-key-via-messagebus/304479 "2024-04-18T15:15:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Alexander](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander/32/497634_2.png) [@Alexander](https://meta.discourse.org/u/Alexander)
#### Post date: [April 18, 2024, 3:15pm UTC](https://meta.discourse.org/t/listen-to-revoked-user-api-key-via-messagebus/304479/1 "2024-04-18T15:15:40Z")

</div>

I am creating a mobile application using React Native powered by Discourse (Communicating via REST Api).

I use the User API Keys flow to make authenticated requests and the MessageBus to listen to different events (Implemented successfully fortunately)

At the moment I am implementing the case where the API Key is revoked, and thus tell the user something similar to “Your session has expired”.

For that I tried to subscribe to `/logout/${current_user.id}` (It seems to be what Discourse uses in the frontend), without any success

Is it possible that I should subscribe to another channel or is that kind of information not currently transmitted via MessageBus?

Relevant code:

```ts
const messageBus = MessageBus.getInstance();
/* Add the User-Api-Key header to message bus */
messageBus.setToken(currentAccount.apiKey);

messageBus.subscribe(`/logout/${currentAccount.id}`, () => {
  console.log(`Logging out account ${currentAccount.username}`);
  alert("Your session has expired. Please log in again.");
  signOut({ reason: REASON_SESSION_EXPIRED });
  /* When Revoken, only delete the account data from the storage */
});

```

Thanks! 🙂

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 22, 2024, 4:14am UTC](https://meta.discourse.org/t/listen-to-revoked-user-api-key-via-messagebus/304479/2 "2024-04-22T04:14:03Z")

</div>

revoking a key is not going to log out all sessions. I think you are going to need to explicitly log people out for them to get that message.
