Tutorial: Pair your device
Many 10-feet devices, like tvOS, Roku or many Smart TVs don't come with an extensive keyboard. However most users have an internet connected mobile phone (or tablet/laptop) close to them while enjoying the big screen. This tutorial explains how to effectively pair a 10-feet device to a Cleeng user account without the user having to enter an email address or password via the limited remote control.
Please see the following sequence diagram:
At the launch of the application you should connect via the middleware and ask the Cleeng API if this device is registered to a given user. If positive the API will return the CustomerToken that can be used within the application to identify the user. If false is returned, the device will still need to be linked to a Cleeng user account.
Start by calling the API method generateDeviceAuthCode() passing on the device specific details like the Serial ID. To restrict further you pass ideally also some user data available in the device via deviceUserId. The Cleeng API will return an authCode, that should be prominently displayed on the screen like in the following example. This code is valid for 5 minutes and can be requested again if required. Along with the AutCode the user should be instructed to go to www.cleeng.com/link in any browser (like on their phone).
The URL (e.g. cleeng.com/link) that contains the web-form to enter the authCode is only accessible after the user logs in to Cleeng. The user is requested to enter the authCode that was displayed on the TV, and once verified using pairDeviceToUser() Cleeng automatically pairs the device to this user account. In the mean-time the client application should keep on polling using the API method getCustomerTokenForDervice( ) like every 5 seconds until the method returns a customerToken or when it is timed out after 5 minutes.
Now the native application is linked to a Cleeng account and has a valid Cleeng customerToken available. This can be used for example to retrieve the details of the user via getCustomer() or to validate entitlements.