diff --git a/discord/state.py b/discord/state.py index cef52afe1..344a60013 100644 --- a/discord/state.py +++ b/discord/state.py @@ -2012,9 +2012,9 @@ class ConnectionState: ) def parse_oauth2_token_revoke(self, data: gw.OAuth2TokenRevokeEvent) -> None: - if 'access_token' not in data: + if 'access_token' not in data or 'application_id' not in data: _log.warning('OAUTH2_TOKEN_REVOKE payload has invalid data: %s. Discarding.', list(data.keys())) - self.dispatch('oauth2_token_revoke', data['access_token']) + self.dispatch('oauth2_token_revoke', data['access_token'], data['application_id']) def parse_auth_session_change(self, data: gw.AuthSessionChangeEvent) -> None: self.auth_session_id = auth_session_id = data['auth_session_id_hash'] diff --git a/discord/types/gateway.py b/discord/types/gateway.py index faaf1fbd9..74135fd2b 100644 --- a/discord/types/gateway.py +++ b/discord/types/gateway.py @@ -468,6 +468,7 @@ class ConnectionsLinkCallbackEvent(TypedDict): class OAuth2TokenRevokeEvent(TypedDict): access_token: str + application_id: Snowflake class AuthSessionChangeEvent(TypedDict): diff --git a/docs/api.rst b/docs/api.rst index 51ceb3969..26eab4f78 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -713,14 +713,20 @@ Notes OAuth2 ~~~~~~~ -.. function:: on_oauth2_token_revoke(token) +.. function:: on_oauth2_token_revoke(token, application_id) Called when an authorized application is revoked. .. versionadded:: 2.0 + .. versionchanged:: 2.1 + + The ``application_id`` parameter was added. + :param token: The token that was revoked. :type token: :class:`str` + :param application_id: The application ID that was revoked. + :type application_id: :class:`int` Calls ~~~~~