createAuthCode method
Creates an authorization code for the specified Connect Customer instance. The authorization code can be used to establish a session with scoped permissions defined by the specified scope parameters.
May throw AccessDeniedException.
May throw InternalServiceException.
May throw InvalidParameterException.
May throw InvalidRequestException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
Parameter instanceId :
The identifier of the Connect Customer instance. You can find
the instance ID in the Amazon Resource Name (ARN) of the instance.
Parameter scope :
The scope for the authorization code. Defines the permissions and access
boundaries for the session.
Parameter sessionInactivityDurationMinutes :
The duration of inactivity, in minutes, after which the session expires.
Minimum value of 1440 (24 hours). Maximum value of 20160 (14 days).
Parameter maxSessionDurationMinutes :
The maximum duration of the session, in minutes. Minimum value of 1440 (24
hours). Maximum value of 43200 (30 days). If no value is provided, the
session will expire after 400 days.
Implementation
Future<CreateAuthCodeResponse> createAuthCode({
required String instanceId,
required AuthScope scope,
required int sessionInactivityDurationMinutes,
int? maxSessionDurationMinutes,
}) async {
_s.validateNumRange(
'sessionInactivityDurationMinutes',
sessionInactivityDurationMinutes,
0,
20160,
isRequired: true,
);
_s.validateNumRange(
'maxSessionDurationMinutes',
maxSessionDurationMinutes,
1440,
43200,
);
final $payload = <String, dynamic>{
'Scope': scope,
'SessionInactivityDurationMinutes': sessionInactivityDurationMinutes,
if (maxSessionDurationMinutes != null)
'MaxSessionDurationMinutes': maxSessionDurationMinutes,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/auth/code/${Uri.encodeComponent(instanceId)}',
exceptionFnMap: _exceptionFns,
);
return CreateAuthCodeResponse.fromJson(response);
}