Once the Loyale SSO process is complete, the user will be redirected to the success_url or error_url respectively.

In case of an error, you will get 2 query parameters error and other. The error parameter will contain a string describing the issue encountered by Loyale during authentication, you can handle it however you see fit.

{error_url}?error={error_message}&other={other_param}

In case of success, you will get 2 query parameters jwt and other. The jwt parameter will contain the Loyale Customer JSON Web Token, which you will use to authenticate the user who made the request on your website.

{success_url}?jwt={jwt}&other={other_param}

To complete the authentication, you must call the Loyale Verify Token endpoint server-side.

curl --location --request POST 'https://api.loyale.io/api/Customer/VerifyToken' \
--header 'accept: */*' \
--header 'X-Scheme: {scheme_id}' \
--header 'Authorization: Bearer {auth_token}' \
--header 'Content-Type: application/json-patch+json' \
--data-raw '{"token":"{jwt}"}'

If the jwt is valid you will get back the Loyale Customer ID to link to your website's user.

{
    "valid": true,
    "customerId": "2d0e88cc-274f-45a4-9c59-ef28142e06af"
}

If it's not valid, the Loyale Customer ID will be null, the property valid will also be false.

{
    "valid": false,
    "customerId": null
}