Widget Auto Sign-In

Bypass widget login screen and automatically redirect your customers to their ambassador's dashboard.

 

Implementation Steps

It might be useful, and also better in terms of user experience, to automatically sign-in your customers to your
referral program, especially if they can access your referral program from a secure environment (their account). This way your customers will be able to directly access their ambassador dashboard seamlessly from there account and share with their friends.
The following lines describe how to easily achieve this using our widget and API jointly.

1. Generate a token

In order to securely auto sign-in a customer, you need to generate a token via the following API endpoint https://incentivit.com/apidoc/v2/#api-Token-TokenGet.
If the customer does exist, the system will create an ambassador profile for the customer and return a token. If the customer already has an ambassador profile, then
the system will update the data (if it differs from the current store data) and return a token.

Here is an example of php code calling the API endpoint to get a token:

//set the url, number of POST vars, POST data
$url = "https://incentivit.com/api/v2/token/5034/$email";
$fields = array(
'userFirstName' => $fname,
'userLastName' => $lname
);
$fields_string = '';
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

$header = array(
'apiKey:votre_api_key',
'secretKey: 'votre_secret_Key
);
//execute post
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
$response = json_decode($result);
//close connection
curl_close($ch);

$token = $response

2. Pass the token to the widget

Once you got the token, you need to pass the token to the widget url as a parameter as follow:

<iframe id="incentivit_iframe" style="min-height: 471px" scrolling="no" allowtransparency="true" src="https://widget.incentivit.com/login.php?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUaWwiOiJsdWNAa=" width="100%" frameborder="0"></iframe>

This will automatically sign-in (and register if required) and redirect the customer to his ambassador dashboard.