admin_revoke_user_session
async
¶
admin_revoke_user_session(
user_pool_id: UserPoolIdType,
username: UsernameType,
session_id: SessionIdType,
*,
config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
revoke_associated_sessions: Optional[RevokeAssociatedSessionsType] = None,
) -> AdminRevokeUserSessionResponse
Revokes a specific user session as an administrator. Amazon Cognito revokes all refresh and access tokens that are associated with the session and deletes the session record. You can revoke either a token session or an SSO session, and you can optionally cascade the revocation to linked sessions.
Parameters:
-
user_pool_id(UserPoolIdType) –The ID of the user pool that contains the session.
-
username(UsernameType) –The username of the user who owns the session. The username must match the user associated with the
SessionId, to confirm they are the intended target user. -
session_id(SessionIdType) –The ID of the session to revoke. This is a 28-character string of lowercase letters and digits, prefixed with
tknfor a token session orssofor an SSO session. -
revoke_associated_sessions(Optional[RevokeAssociatedSessionsType], default:None) –Specifies whether to also revoke the sessions that are linked to the targeted session.
NONE, the default, revokes only the targeted session.LINKEDalso revokes the directly linked session or sessions, interpreted relative to the type of the targeted session: revoking a token session also revokes the parent SSO session it came through, and revoking an SSO session also revokes the token sessions that came through it. The set of linked sessions is eventually consistent, so associated sessions are typically revoked within a few seconds.
Raises:
-
InternalErrorException–This exception is thrown when Amazon Cognito encounters an internal error.
-
InvalidParameterException–This exception is thrown when the Amazon Cognito service encounters an invalid parameter.
-
NotAuthorizedException–This exception is thrown when a user isn't authorized.
-
OperationNotEnabledException–This exception is thrown when an operation is not available in the current region or for the current user pool configuration. This can occur when attempting to perform operations that are not supported in secondary replica regions.
-
ResourceNotFoundException–This exception is thrown when the Amazon Cognito service can't find the requested resource.
-
TooManyRequestsException–This exception is thrown when the user has made too many requests for a given operation.
-
UserNotFoundException–This exception is thrown when a user isn't found.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Example revoke a user session as an administrator The following example revokes a token session for the user testuser and cascades the revocation to the parent SSO session that the token session came through.
>>> await client.admin_revoke_user_session(user_pool_id='us-east-1_EXAMPLE', username='testuser', session_id='tknm5k9p2q7r4s8t1v6w3x0y5z2b', revoke_associated_sessions='LINKED')
Source code in docs_src/capo_cognito_identity_provider/_services/async_cognito_identity_provider.py
2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 | |