Creates an encrypted token that is used by a chat participant to establish an individual WebSocket chat connection to a room. When the token is used to connect to chat, the connection is valid for the session duration specified in the request. The token becomes invalid at the token-expiration timestamp included in the response.
Use the capabilities field to permit an end user to send messages or moderate a room.
The attributes field securely attaches structured data to the chat session; the data is included within each message sent by the end user and received by other participants in the room. Common use cases for attributes include passing end-user profile data like an icon, display name, colors, badges, and other display features.
Encryption keys are owned by Amazon IVS Chat and never used directly by your application.
Parameters:
-
room_identifier
(RoomIdentifier)
–
Identifier of the room that the client is trying to access. Currently this must be an ARN.
-
user_id
(UserID)
–
Application-provided ID that uniquely identifies the user associated with this token. This can be any UTF-8 encoded text.
-
capabilities
(Optional[ChatTokenCapabilities], default:
None
)
–
Set of capabilities that the user is allowed to perform in the room. Default: None (the capability to view messages is implicitly included in all requests).
-
session_duration_in_minutes
(Optional[SessionDurationInMinutes], default:
None
)
–
Session duration (in minutes), after which the session expires. Default: 60 (1 hour).
-
attributes
(Optional[ChatTokenAttributes], default:
None
)
–
Application-provided attributes to encode into the token and attach to a chat session. Map keys and values can contain UTF-8 encoded text. The maximum length of this field is 1 KB total.
Raises:
Source code in docs_src/capo_ivschat/_services/ivschat.py
| def create_chat_token(
self,
room_identifier: "capo_ivschat.types.room_identifier.RoomIdentifier",
user_id: "capo_ivschat.types.user_id.UserID",
*,
config_overrides: Optional[ivschatClientConfig] = None,
capabilities: Optional[
"capo_ivschat.types.chat_token_capabilities.ChatTokenCapabilities"
] = None,
session_duration_in_minutes: Optional[
"capo_ivschat.types.session_duration_in_minutes.SessionDurationInMinutes"
] = None,
attributes: Optional[
"capo_ivschat.types.chat_token_attributes.ChatTokenAttributes"
] = None,
) -> "capo_ivschat.types.create_chat_token_response.CreateChatTokenResponse":
"""<p>Creates an encrypted token that is used by a chat participant to establish an individual WebSocket chat connection to a room. When the token is used to connect to chat, the connection is valid for the session duration specified in the request. The token becomes invalid at the token-expiration timestamp included in the response.</p> <p>Use the <code>capabilities</code> field to permit an end user to send messages or moderate a room.</p> <p>The <code>attributes</code> field securely attaches structured data to the chat session; the data is included within each message sent by the end user and received by other participants in the room. Common use cases for attributes include passing end-user profile data like an icon, display name, colors, badges, and other display features.</p> <p>Encryption keys are owned by Amazon IVS Chat and never used directly by your application.</p>
Args:
room_identifier: <p>Identifier of the room that the client is trying to access. Currently this must be an ARN. </p>
user_id: <p>Application-provided ID that uniquely identifies the user associated with this token. This can be any UTF-8 encoded text.</p>
capabilities: <p>Set of capabilities that the user is allowed to perform in the room. Default: None (the capability to view messages is implicitly included in all requests).</p>
session_duration_in_minutes: <p>Session duration (in minutes), after which the session expires. Default: 60 (1 hour).</p>
attributes: <p>Application-provided attributes to encode into the token and attach to a chat session. Map keys and values can contain UTF-8 encoded text. The maximum length of this field is 1 KB total.</p>
Raises:
capo_ivschat.errors.access_denied_exception.AccessDeniedException: <p/>
capo_ivschat.errors.pending_verification.PendingVerification: <p/>
capo_ivschat.errors.resource_not_found_exception.ResourceNotFoundException: <p/>
capo_ivschat.errors.validation_exception.ValidationException: <p/>
capo_ivschat.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_ivschat.types.create_chat_token_request.CreateChatTokenRequest]",
) -> OperationResponse[
"capo_ivschat.types.create_chat_token_response.CreateChatTokenResponse"
]:
import capo_ivschat._operations.amazon_interactive_video_service_chat.create_chat_token
output, http_response = (
capo_ivschat._operations.amazon_interactive_video_service_chat.create_chat_token.create_chat_token(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_ivschat.types.create_chat_token_request.CreateChatTokenRequest",
) -> dict[str, Any]:
import capo_ivschat.types.create_chat_token_request
return capo_ivschat.types.create_chat_token_request.redact_sensitive(input_)
def _redact_output(
output: "capo_ivschat.types.create_chat_token_response.CreateChatTokenResponse",
) -> dict[str, Any]:
import capo_ivschat.types.create_chat_token_response
return capo_ivschat.types.create_chat_token_response.redact_sensitive(
output
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging(
"CreateChatToken",
redact_input=_redact_input,
redact_output=_redact_output,
),
)
input_: capo_ivschat.types.create_chat_token_request.CreateChatTokenRequest = {
"room_identifier": room_identifier,
"user_id": user_id,
}
if capabilities is not None:
input_["capabilities"] = capabilities
if session_duration_in_minutes is not None:
input_["session_duration_in_minutes"] = session_duration_in_minutes
if attributes is not None:
input_["attributes"] = attributes
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|