createParticipantToken method
Creates an additional token for a specified stage. This can be done after stage creation or when tokens expire. Tokens always are scoped to the stage for which they are created.
Encryption keys are owned by Amazon IVS and never used directly by your application.
May throw AccessDeniedException.
May throw PendingVerification.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ValidationException.
Parameter stageArn :
ARN of the stage to which this token is scoped.
Parameter attributes :
Application-provided attributes to encode into the token and attach to a
stage. Map keys and values can contain UTF-8 encoded text. The maximum
length of this field is 1 KB total. This field is exposed to all stage
participants and should not be used for personally identifying,
confidential, or sensitive information.
Parameter capabilities :
Set of capabilities that the user is allowed to perform in the stage.
Default: PUBLISH, SUBSCRIBE.
Parameter duration :
Duration (in minutes), after which the token expires. Default: 720 (12
hours).
Parameter userId :
Name that can be specified to help identify the token. This can be any
UTF-8 encoded text. This field is exposed to all stage participants and
should not be used for personally identifying, confidential, or sensitive
information.
Implementation
Future<CreateParticipantTokenResponse> createParticipantToken({
required String stageArn,
Map<String, String>? attributes,
List<ParticipantTokenCapability>? capabilities,
int? duration,
String? userId,
}) async {
_s.validateNumRange(
'duration',
duration,
1,
20160,
);
final $payload = <String, dynamic>{
'stageArn': stageArn,
if (attributes != null) 'attributes': attributes,
if (capabilities != null)
'capabilities': capabilities.map((e) => e.value).toList(),
if (duration != null) 'duration': duration,
if (userId != null) 'userId': userId,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/CreateParticipantToken',
exceptionFnMap: _exceptionFns,
);
return CreateParticipantTokenResponse.fromJson(response);
}