Shopify Login as Customer API

Customer support is improved significantly with the Shopify Login as Customer App since you can assist customers in placing orders and fixing account-related issues timely. But that's not it.

Shopify store admin is not the only place where you can log in to your customers' accounts from. You can also log in to customer accounts from your CRM or helpdesk, etc., if they allow you to extend them and run requests to custom API that comes with our app.

You can log in to customer accounts using API in 2 different ways. 

Note: the following code is written in PHP, but you can use any other programming language.

Log in As a Customer using the Customer ID

<?php
$publicKey = '****************';
$secretKey = '***********************************';

$shop = '**********'; // for example 'myshop.myshopify.com';
$customer = '**********'; //for example 123456789;
?>
<?php
$currentDate = date('Y-m-d');
$token = hash('sha256', $publicKey . $secretKey . $currentDate . $secretKey . $customer . $publicKey);
$url = 'https://lac.sfapp.magefan.top/api/login?public_key=' . $publicKey . '&customer_id=' . $customer . '&shop=' . $shop;
/* Uncomment next line in case the multi-pass feature is not available for your Shopify account, it will reset the user password and perform login. */
// $url .= '&change_pwd_flag=1';
?>

<form action="<?= $url ?>" method="POST">
<input type="hidden" name="token" value="<?= $token ?>">
<input type="submit" value="Login As Customer: ID <?= $customer ?>">
</form>

Log in As a Customer using the Customer Email

<?php
$publicKey = '****************';
$secretKey = '***********************************';

$shop = '**********'; // for example 'myshop.myshopify.com';
$customer = '**********'; //for example 'jon.doe@domain.com';
?>
<?php
$currentDate = date('Y-m-d');
$token = hash('sha256', $publicKey . $secretKey . $currentDate . $secretKey . $customer . $publicKey);
$url = 'https://lac.sfapp.magefan.top/api/login?public_key=' . $publicKey . '&email=' . $customer . '&shop=' . $shop;
/* Uncomment next line in case the multi-pass feature is not available for your Shopify account, it will reset the user password and perform login. */
// $url .= '&change_pwd_flag=1';
?>

<form action="<?= $url ?>" method="POST">
<input type="hidden" name="token" value="<?= $token ?>">
<input type="submit" value="Login As Customer Email: <?= $customer ?>">
</form>

Here you'll find the $publicKey and $secretKey values which you have to substitute with unique values from your store. For that read the following article about how to get public and secret keys for login as customer API.

Values of the variable $shop should be replaced with your shop domain name, and $customer variable value should be replaced with your customer ID or email.