revoke_user_session
¶
revoke_user_session(
access_token: TokenModelType,
session_id: SessionIdType,
*,
config_overrides: Optional[CognitoIdentityProviderClientConfig] = 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.
>>> client.revoke_user_session(access_token='eyJra456defEXAMPLE', session_id='tknm5k9p2q7r4s8t1v6w3x0y5z2b', revoke_associated_sessions='NONE')
Source code in docs_src/capo_cognito_identity_provider/_services/cognito_identity_provider.py
9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 | |