createMicrovmAuthToken method
Creates an authentication token for accessing a running MicroVM. The token grants access to the specified ports on the MicroVM endpoint.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw ValidationException.
Parameter allowedPorts :
The list of port specifications that the authentication token grants
access to on the MicroVM.
Parameter expirationInMinutes :
The duration in minutes before the authentication token expires. Maximum:
60 minutes.
Parameter microvmIdentifier :
The ID of the MicroVM to create an authentication token for.
Implementation
Future<CreateMicrovmAuthTokenResponse> createMicrovmAuthToken({
required List<PortSpecification> allowedPorts,
required int expirationInMinutes,
required String microvmIdentifier,
}) async {
_s.validateNumRange(
'expirationInMinutes',
expirationInMinutes,
1,
1152921504606846976,
isRequired: true,
);
final $payload = <String, dynamic>{
'allowedPorts': allowedPorts,
'expirationInMinutes': expirationInMinutes,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/2025-09-09/microvms/${Uri.encodeComponent(microvmIdentifier)}/auth-token',
exceptionFnMap: _exceptionFns,
);
return CreateMicrovmAuthTokenResponse.fromJson(response);
}