createManagedLoginBranding method

Future<CreateManagedLoginBrandingResponse> createManagedLoginBranding({
  1. required String clientId,
  2. required String userPoolId,
  3. List<AssetType>? assets,
  4. Object? settings,
  5. bool? useCognitoProvidedValues,
})

Creates a new set of branding settings for a user pool style and associates it with an app client. This operation is the programmatic option for the creation of a new style in the branding editor.

Provides values for UI customization in a Settings JSON object and image files in an Assets array. To send the JSON object Document type parameter in Settings, you might need to update to the most recent version of your Amazon Web Services SDK. To create a new style with default settings, set UseCognitoProvidedValues to true and don't provide values for any other options.

This operation has a 2-megabyte request-size limit and include the CSS settings and image assets for your app client. Your branding settings might exceed 2MB in size. Amazon Cognito doesn't require that you pass all parameters in one request and preserves existing style settings that you don't specify. If your request is larger than 2MB, separate it into multiple requests, each with a size smaller than the limit.

Learn more

May throw ConcurrentModificationException. May throw InternalErrorException. May throw InvalidParameterException. May throw LimitExceededException. May throw ManagedLoginBrandingExistsException. May throw NotAuthorizedException. May throw OperationNotEnabledException. May throw ResourceNotFoundException. May throw TooManyRequestsException.

Parameter clientId : The app client that you want to create the branding style for. Each style is linked to an app client until you delete it.

Parameter userPoolId : The ID of the user pool where you want to create a new branding style.

Parameter assets : An array of image files that you want to apply to functions like backgrounds, logos, and icons. Each object must also indicate whether it is for dark mode, light mode, or browser-adaptive mode.

Parameter settings : A JSON file, encoded as a Document type, with the the settings that you want to apply to your style.

The following components are not currently implemented and reserved for future use:

Parameter useCognitoProvidedValues : When true, applies the default branding style options. These default options are managed by Amazon Cognito. You can modify them later in the branding editor.

When you specify true for this option, you must also omit values for Settings and Assets in the request.

Implementation

Future<CreateManagedLoginBrandingResponse> createManagedLoginBranding({
  required String clientId,
  required String userPoolId,
  List<AssetType>? assets,
  Object? settings,
  bool? useCognitoProvidedValues,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target':
        'AWSCognitoIdentityProviderService.CreateManagedLoginBranding'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ClientId': clientId,
      'UserPoolId': userPoolId,
      if (assets != null) 'Assets': assets,
      if (settings != null) 'Settings': settings,
      if (useCognitoProvidedValues != null)
        'UseCognitoProvidedValues': useCognitoProvidedValues,
    },
  );

  return CreateManagedLoginBrandingResponse.fromJson(jsonResponse.body);
}