Using the Entitlements option

What are entitlements?

Entitlements are a way to allow an external system to determine which content a specific user can have access to. In the world of magazines, this is most frequently used to allow print subscribers to automatically access the digital editions.

However, the entitlements solution in Twixl Publisher is flexible enough to implement use cases that go further than just allowing print subscribers to have access to the contents.

Here are some other examples of what is possible:

Entitlements influence the list of issues that a user can see, download or purchase in the kiosk. It does not have an influence on the actual content of an issue itself.

Prerequisites

To use entitlements in your application, you will need:

How entitlements work

When you create an application that supports entitlements, there are several steps in the process to get this working.

Build settings in the Twixl Publisher OS X app

Build settings in the Twixl Publisher OS X app

Enable entitlements in your app build. This is configured in the build settings under "App Store Kiosk - Entitlements". You will need to enter the following parameters:

tp-entitlements-signin://self

or

tp-entitlements-register://self

Twixl Distribution Platform Configuration

Twixl Distribution Platform Configuration

Then, you can enter user details manually or use the Twixl Distribution Platform Admin API to automatically add, remove or update entitlement info.

Print Subscriber example

Print Subscriber example

When users open the app, they will see a screen that looks like the one above.

When the user then taps the "Login As Print Subscriber" link, this will trigger the special url "tp-entitlements-signin://self", open up a modal dialog and show the output of the "signin_form" API call of the entitlements server.

Note that the user needs to be online for this to work.

Print Subscriber

In this example, a form is displayed that can be used for login/password authentication, but it's up to the publisher to decide which types of information are requested from the user.

Sign in Form

What is important is that the form submits its parameters using a GET request and that it includes the hidden form parameter called "do" which should be set to "signin". This is required so that the application can catch this and add extra parameters to this action.

<form method="GET"> <input type="hidden" name="do" value="signin" /> <input type="text" name="email" /> <input type="password" name="password" /> </form>

You can also use a hyperlink to do trigger the signin. You can specify the link as follows:

<a href="?do=signin®ion=UK">Select UK</a>

Submit form

When the user then submits the form or taps the link, the application will catch the "signin" request and will add the following extra parameters:

Using these parameters, a POST request will be sent to the signin action on the Entitlements Server to verify the data. The signin action should return a JSON dictionary with one key in there called "token". This will be used in all subsequent calls to identify the user or device.

{"token": "248335453156"}

If something goes wrong or when e.g. the user is not known, an error should be returned. The output should be:

{"error": "Unknown subscriber."}

Sign in succeeded/error

Depending on the result of the signin action, the app will present a new web page, using either the "signin_succeeded" or "signin_error" action on the Entitlements Server. Both actions will receive an extra parameter in the query string:

signin_succeeded: token

This can be used to show e.g. the subscriber details.

signin_error: error

This can be used to show an error message to the user explaining why the signin failed.

If you don't want to show anything and just close the popup window or provide the user with a button to do so, you can use the following special link:

tp-close://self

Product Identifiers

Every time the application now reloads the contents of the store or when someone wants to purchase an issue, the Twixl Distribution Platform will perform the "entitlements" API call on the Entitlements Server. It will check which product_identifiers a user is entitled for and will allow free access to these issues if so.

Custom Entitlements Server

If you prefer to use your own entitlements server instead of using the built-in options, then refer to our separate article.