revoke_user_session
async
¶
revoke_user_session(
access_token: TokenModelType,
session_id: SessionIdType,
*,
config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
revoke_associated_sessions: Optional[RevokeAssociatedSessionsType] = None,
) -> RevokeUserSessionResponse
Revokes a specific session for the currently signed-in user. Amazon Cognito authorizes this operation with the user's access token, revokes all refresh and access tokens that are associated with the session, and deletes the session record. You can't revoke the session that the calling access token belongs to.
Parameters:
-
access_token(TokenModelType) –A valid access token that Amazon Cognito issued to the user. Amazon Cognito uses this token to authorize the request and to identify the 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. This value can't identify the caller's own current 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:
-
ForbiddenException–This exception is thrown when WAF doesn't allow your request based on a web ACL that's associated with your user pool.
-
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.
-
PasswordResetRequiredException–This exception is thrown when a password reset is required.
-
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.
-
UserNotConfirmedException–This exception is thrown when a user isn't confirmed successfully.
-
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 one of a user's own sessions The following example revokes a single token session that belongs to the user who owns the provided access token, such as signing out a lost or stolen device. Only the targeted session is revoked.
>>> await client.revoke_user_session(access_token='eyJra456defEXAMPLE', session_id='tknm5k9p2q7r4s8t1v6w3x0y5z2b', revoke_associated_sessions='NONE')
Source code in docs_src/capo_cognito_identity_provider/_services/async_cognito_identity_provider.py
10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 | |