1

When creating a user with Amplify, I am calling amplify.createUser(email, password).

When using Cognito, you can use Auth.SignUp() with an attributes parameter to assign Cognito user pool attributes to the user. Is there anyway to do this with Amplify?

I basically want to sign up a user and set some Cognito user pool attributes at the same time.

2 Answers 2

3

This functionality has not yet been implemented in Amplify for Android but is scheduled to be finished in the near future, as noted in this documentation. Please check back to the documentation for updates on availability.

In the meantime though, you can still use Amplify. Just access the underlying AWSMobileClient through the authentication escape hatch, which does support passing custom attributes. See this documentation for more details on how exactly to use AWSMobileClient.

Sign up to request clarification or add additional context in comments.

1 Comment

hey this is exactly what I was looking for thank you so much
1

I don't know if this is still relevant, but here is how to accomplish the task with Amplify.

First you build an AuthSignUpOptions object (example of custom attribute and standard attribute below):

AuthSignUpOptions options = AuthSignUpOptions.builder() .userAttribute(AuthUserAttributeKey.custom("custom:role"), "some_role") .userAttribute(AuthUserAttributeKey.address(), "some_address") .build(); 

Then call Amplify.Auth.signup:

Amplify.Auth.signUp("username", "password", options, result -> { /* do something */ }, error -> { /* do something */ }); 

Altogether it looks like this:

AuthSignUpOptions options = AuthSignUpOptions.builder() .userAttribute(AuthUserAttributeKey.custom("custom:role"), "some_role") .userAttribute(AuthUserAttributeKey.address(), "some_address") .build(); Amplify.Auth.signUp(tempUsername.getText().toString(), pin.getText().toString(), options, result -> { /* do something */ }, error -> { /* do something */ }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.