authenticateCustomer
Authenticate a customer with a signed payload.
To authenticate customers, generate a signature on your server and call the authentication method.
signature = sha1("{shopifyCustomerId}{signatureTimestamp}{secretKey}")
shopifyCustomerId: The Shopify customer ID.signatureTimestamp: The Unix timestamp when the signature is created.secretKey: Your secret key from the Growave admin panel.
Security
Always generate signatures on your server to keep your secretKey safe.
sdk.authentication.methods.authenticateCustomer()authenticateCustomer(params: { shopifyCustomerId: number; signature: string; signatureTimestamp: number }): Promise<Success>Parameters
params{ shopifyCustomerId: number; signature: string; signatureTimestamp: number }- Authentication parameters object.
Returns
Promise<Success>Promise that resolves to a success result once the request is processed, or rejects with an error. If `logoutCustomer()`, `setToken()` or another `authenticateCustomer()` call was made while this request was in flight, the later call wins and this result is not applied. Check the outcome with {@link getCurrentRole}.
Usage example
Ensure the SDK is ready and the AuthenticationSdk module is initialized, then call authenticateCustomer.
function onSdkReady() {
window.gw.sdk.runIfModuleReady(
window.gw.sdk.common.constants.modules.AUTHENTICATION,
() => {
window.gw.sdk.authentication.methods.authenticateCustomer({
shopifyCustomerId,
signatureTimestamp,
signature,
});
}
);
}
if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}