Amplify-js: POST https://cognito-identity.eu-west-1.amazonaws.com/ 400 (Bad Request)

Created on 30 Aug 2018  路  7Comments  路  Source: aws-amplify/amplify-js

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Iam using AWS Amplify JS library in my Web-Application, the problem is that in each Authentication request or refreshing my browser I used to see "POST https://cognito-identity.eu-west-1.amazonaws.com/ 400 (Bad Request)".

My understanding is that calling

import aws_exports from './aws-exports';

leads to AWS sending post request using 'aws_cognito_identity_pool_id', When I remove

'aws_cognito_identity_pool_id': 'eu-west-1:xxxxxxxxxxx',

from the configuration file I do not see this error message (no more post request).

Do you have any suggestion/idea why such error comes, and why the Aws_Amplify_Api used to post requests every time './aws-exports' is imported?

Here is my config file:

const awsmobile = {
    'aws_cognito_identity_pool_id': 'eu-west-1:xxxxxxx',
    'aws_cognito_region': 'eu-west-1',
    'aws_facebook_app_id': '34534534534545',
    'aws_facebook_app_permissions': 'public_profile,email',
    'aws_google_app_permissions': 'email,profile,openid',
    'aws_google_web_app_id': '345345345-apps.googleusercontent.com',
    'aws_user_files': 'enable',
    'aws_user_files_s3_bucket': 'abc',
    'aws_user_files_s3_bucket_region': 'eu-west-1',
    'aws_project_name': 'abc',
    'aws_user_pools': 'enable',
    'aws_user_pools_id': 'eu-west-1_xxxxxxx',
    'aws_user_pools_web_client_id': 'xxxxxxxxxx',
    'aws_user_pools_arn': 'arn:aws:cognito-idp:eu-west-1:55555555:userpool/eu-west-1_xxxxxxx',
    'aws_user_pools_mfa_type': 'OFF',
};

export default awsmobile;
Auth question

All 7 comments

@engharb the Cognito Federated Identity Pool is used to get an AWS credentials for you. If you provide the identity pool id to the library, it will try to get you a guest credentials when your app is loaded. If your identity pool doesn't allow unauthenticated access, then you will get this post error.

@engharb if you are not familiar with setting up unauthenticated access in Cognito, you may choose to use the new Amplify CLI: https://aws-amplify.github.io/amplify-js/media/authentication_guide

@powerful23 , @undefobj Already I have activated the option: Enable access to unauthenticated identities in my identity pool, but I still have the same error message. Do I need to do some changes to the configuration/settings in 'awsmobile'?

thanks a lot for support. Actually I have created a new Unauth_Role.

thanks a lot for support. Actually I have created a new Unauth_Role.

@engharb can you share mode details about the unauth_role that you created to solve this?

@engharb can you share bit about how you solved the issues?

I solved it this way:

Goto Amazon Cognito > Manage Identity Pool > (Click in your Identity Pool) > Edit identity pool
image
And check: Enable access to unauthenticated identities
image
And save changes
image

Was this page helpful?
0 / 5 - 0 ratings