signIn
Method that signs in a customer that exists in a customers list in Salesforce Commerce Cloud.
This method runs for both OCAPI and SCAPI. In addition to customer data, it also returns updated JWT tokens and USID, similar to how guest authentication is handled. It communicates with the signIn endpoint of the Vue Storefront API Middleware. For OCAPI, it calls the Get or refresh customer JWT resource, passing the customer credentials in a basic authorization header. For SCAPI, it goes through the Registered User (B2C Commerce Login) Private Client SLAS Flow, which involves authenticating the customer, receiving an authorization code in a callback and getting an access token using the code.
You can use this method to authenticate an existing customer and have all subsequent calls happen in the context of that customer.
Signature
export declare function signIn(
props: SignInCredentials
): Promise<CustomerData>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | SignInCredentials | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
Returns
Returns a representation of the basic data of the logged-in customer.
Referenced Types
SignInCredentialsCustomerData
Examples
Signing in a customer with a username and password.
import { sdk } from '~/sdk.config.ts';
const category = await sdk.commerce.signIn({ username: 'testuser1@demandware.com', password: 'Test123!' });