question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

boto3 cognito : set_ui_customization call not working.

See original GitHub issue

I am trying to upload logo file for custom UI for Hosted Domain. Below is my source code.

def readImage():
        with open("./utils/png-file-6-1.png", "rb") as image:
            f = image.read()
            b = bytearray(f)
            return b

def set_ui_customization():
        bytes_a = readImage()
        client = boto3.client('cognito-idp', region_name=self.region_name)
        response = client.set_ui_customization(
            UserPoolId='abc',
            ClientId='pqr',
            #CSS='string',
            ImageFile=bytes_a
            )
        print('done')
        print(response)

Its giving error :

Traceback (most recent call last): File “/var/task/verify.py”, line 28, in lambda_handler cognito.set_ui_customization(‘abc’, ‘pqr’) File “/var/task/utils/cognitoUtils.py”, line 320, in set_ui_customization response = client.set_ui_customization( File “/var/runtime/botocore/client.py”, line 272, in _api_call return self._make_api_call(operation_name, kwargs) File “/var/runtime/botocore/client.py”, line 576, in _make_api_call raise error_class(parsed_response, operation_name) botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameterException) when calling the SetUICustomization operation: The uploaded image must be a valid .jpeg or .png file.

  1. The provided file is working from AWS console UI, but not from boto3 functions.
  2. Do you have any sample code for how to provide “ImageFile”. Documentation just says Uploaded image file which is not sufficient.

@swetashre : Could you please help on this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gdhananjaycommented, Mar 5, 2020

@vlakken ,

For cli please give image file argument like, --image-file fileb://./Logo.png Please refer : https://stackoverflow.com/questions/50692326/invalid-png-format-in-set-ui-customization-in-aws-cognito

0reactions
gdhananjaycommented, Mar 11, 2020

@swetashre ,

Thanks for the reply, Problem was with my image file, I changed it and it started working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SetUICustomization - Amazon Cognito - AWS Documentation
Sets the user interface (UI) customization information for a user pool's built-in app UI.
Read more >
CognitoIdentityProvider — Boto3 Docs 1.26.34 documentation
To configure custom validation, you must create a Pre Sign-up Lambda trigger for the user pool as described in the Amazon Cognito Developer...
Read more >
Invalid PNG format in set-ui-customization in aws cognito
But it is giving me an error that my PNG File is not valid. I have seen the documentation and found that image-file...
Read more >
aws cognito without hosted ui - La Calabrisella 2
Use the Amazon Cognito SetUICustomization API operation to set the image. ... and helping them use AWS Cognito without running into all the...
Read more >
What is the Python code for AWS Cognito? - Educative.io
Sign-up using AWS Cognito, Python SDK Boto3. import os ... when calling the InitiateAuth operation: USER_PASSWORD_AUTH flow not enabled for this client.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found