associateSoftwareToken method

Future<AssociateSoftwareTokenResponse> associateSoftwareToken({
  1. String? accessToken,
  2. String? session,
})

Returns a unique generated shared secret key code for the user account. The request takes an access token or a session string, but not both.

May throw ConcurrentModificationException. May throw InvalidParameterException. May throw NotAuthorizedException. May throw ResourceNotFoundException. May throw InternalErrorException. May throw SoftwareTokenMFANotFoundException.

Parameter accessToken : The access token.

Parameter session : The session which should be passed both ways in challenge-response calls to the service. This allows authentication of the user as part of the MFA setup process.

Implementation

Future<AssociateSoftwareTokenResponse> associateSoftwareToken({
  String? accessToken,
  String? session,
}) async {
  _s.validateStringLength(
    'session',
    session,
    20,
    2048,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityProviderService.AssociateSoftwareToken'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (accessToken != null) 'AccessToken': accessToken,
      if (session != null) 'Session': session,
    },
  );

  return AssociateSoftwareTokenResponse.fromJson(jsonResponse.body);
}