Amplify-js: Amplify.configure()'s cognito call fails when user-signin does not support unauth users

Created on 15 Feb 2018  路  9Comments  路  Source: aws-amplify/amplify-js

Minor bug: shows up in the web console as a failed POST:

POST https://cognito-identity.us-east-2.amazonaws.com/ 400 (Bad Request)

Steps:

  • Configure a MobileHub project with the User sign-in feature enabled and required.
  • Add a web app to the project, initialize with create-react-app and awsmobile pull
  • Add Amplify.configure(awsmobilejs) as usual.
  • Run npm start and examine the web console.

I would expect Amplify to notice that sign-in is required, and not attempt any Cognito calls prior to sign-in.

Amplify 0.2.6 does not seem to use the aws_mandatory_sign_in element of aws-exports.js.

bug

Most helpful comment

It seems that I should set mandatorySignIn to true, then the error will go.

All 9 comments

@ceich thanks for your feedback!

@ceich this bug has been fixed in the latest release. Please feel free to reopen the issue if neccessary.

I no longer see this at configure() time, but do see this and another error at federated login time. Do you want me to submit a new issue, or to reopen this one?

I do see this when call

AwsAuth.configure({
  identityPoolId: 'xxx',
  region: 'xxx',
  userPoolId: 'xxx',
  userPoolWebClientId: 'xxx',
  mandatorySignIn: false,
});

if I don't pass identityPoolId, I would not see the error. The problem is that I cannot know what's wrong here, the body of the 400 response is just an alien string to me

It seems that I should set mandatorySignIn to true, then the error will go.

+1

It's because if you have the identitypoolId then Amplify will automatically try to get a guest credentials for you which will lead to that http request failing because you didn't turn the mandatorySignIn to true.

Could not find any the mandatory option.

This is what worked for me:
in: amplify/backend/auth/[PROJECT]/parameters.json
set: "allowUnauthenticatedIdentities": true

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benevolentprof picture benevolentprof  路  3Comments

romainquellec picture romainquellec  路  3Comments

TheRealRed7 picture TheRealRed7  路  3Comments

simon998yang picture simon998yang  路  3Comments

callmekatootie picture callmekatootie  路  3Comments