amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Can't sign up with custom attribute of cognito by using Auth.signUp

Open yukitaka13-1110 opened this issue 7 years ago • 10 comments

Problem

Auth In aws-amplify and vue, I found the documents as follows

https://aws.amazon.com/jp/blogs/mobile/aws-amplify-adds-support-for-custom-attributes-in-amazon-cognito-user-pools/

I tried this but failed.

I found same issue as follows

#2167

I try again but failed with the following error.

{
    code: "InvalidParameterException", name: "InvalidParameterException",
    message: "Attributes did not conform to the schema: custom:s…re_name: Attribute does not exist in the schema.↵"
}

Why did this error occured ?

 private get signUpParams () : SignUpParams {
    return {
      username: this.username,
      password: this.password,
      attributes: {
        email: this.email,
        family_name: this.familyName,
        given_name: this.givenName,
        'custom:store_name': this.storename
      }
    }
  }

  private handleSignUpClick () {
    const self = this
    Auth.signUp(self.signUpParams)
      .then(user => {
        return router.push('/verify')
      }).catch(err => {
        console.error(err)
      })
  }

Depencency

aws-amplify => 1.1.29 aws-amplify-vue => 0.2.12

yukitaka13-1110 avatar Jun 27 '19 12:06 yukitaka13-1110

@yukitaka13-1110 Hi, you need to add the custom attribute into your user pool schema which is in the Cognito User Pool Console -> Attributes: Screen Shot 2019-06-29 at 9 40 40 PM

powerful23 avatar Jun 30 '19 04:06 powerful23

Thank you for response !

I know the way to add custom attirbutes using cognito userpool console. I want to add custom attribute schema using aws-amplify or amplify-cli because it is troublesome to set each time of deployment.

Is there a way to do this using amplify-js or amplify-cli ? I think it is a function that everyone wants

yukitaka13-1110 avatar Jun 30 '19 06:06 yukitaka13-1110

@yukitaka13-1110 you can do this by using amplify-js but this might be achieved by using cli(I'm not sure). I will transfer this issue to the cli repo.

powerful23 avatar Jul 01 '19 16:07 powerful23

Thank you for transfering !

yukitaka13-1110 avatar Jul 02 '19 16:07 yukitaka13-1110

@yukitaka13-1110 I beleive you have another thread where you were able to figure out how to add custom attributes to your user-pool cloudformation configurations on create. Closing this issue for now. Feel free to re-open if you've further questions.

kaustavghosh06 avatar Jul 03 '19 05:07 kaustavghosh06

@kaustavghosh06 I could do it. Thank you so mush !

yukitaka13-1110 avatar Jul 03 '19 05:07 yukitaka13-1110

I have added the custom attributes, but it failed to signUp with my attributes value.

I am using aws-amplify-react-native package.

Here I need to change only the UI for signUp. But the functionality of the screen is same as the default signUp screen.

I have used Auth.signUp method to make the signUp, but it failed to signUP.

Anyone can clarify this. Attributes did not conform to the schema: name: The attribute is required\n

Auth.signUp({
			username: this.state.email,
			password: this.state.password,
			attributes: {email: this.state.email},
		})

Note: My default screens works fine before. Customized UI is not working.

nihp avatar Apr 08 '20 11:04 nihp

In case if custom attributes, you need to go to your respective client settings and check this attribute as readable and writable.

zohaib-enquizit avatar Jan 11 '21 14:01 zohaib-enquizit

@nihp please check your parameter json ``` "requiredAttributes": [ "email", "preferred_username" ],


for auth via email, I think you need to pass `preferred_username`. in my case its worked.

    ```
final option = CognitoSignUpOptions(userAttributes: {
      'email': email.trim(),
      'preferred_username': username.trim()
    });

    try {
      final res = await Amplify.Auth.signUp(
          username: email.trim(), password: password.trim(), options: option);
      return res.isSignUpComplete;
    } catch (e) {
      throw e;
    }

yathu avatar May 09 '21 07:05 yathu

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

github-actions[bot] avatar Jun 08 '21 07:06 github-actions[bot]