SDK Example: Authenticate a User (Winter ‘20)

Use the example SDK code in this topic to sign in or sign up a user and authenticate.

1// Instantiate the input object for authenticateUser to specify parameters
2const input = digitalCommerce.createAuthenticateUserInput();
3input.email = "YOUR EMAIL ID";
4input.password = "YOUR PASSWORD";
5input.phoneNumber = "1234567889";
6input.firstName = "YOUR FIRST NAME";
7input.lastName = "YOUR LAST NAME";
8input.signUp = true; // optional - default is false
9
10// Invoke authenticateUser API
11digitalCommerce
12  .authenticateUser(input)
13  .then(response => {
14    Logger.info(
15      "Vlocity digital commerce authenticateUser: " + JSON.stringify(response)
16    );
17  })
18  .catch(error => {
19    Logger.info("authenticateUser apexrest call failed" + error);
20  });

Possible error conditions:

“AuthenticateUserInput::getRequestPayload() must have email.”

“AuthenticateUserInput::getRequestPayload() must have password.”

“AuthenticateUserInput::getRequestPayload() must have phoneNumber.”

“AssetToBasketInput::getRequestPayload() must have rootAssetIds.”

“AuthenticateUserInput::getRequestPayload() must have firstName.”

“AuthenticateUserInput::getRequestPayload() must have lastName.