Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
lumaflix
Level 7

Need advise on Registration and linking

Hi,
would like to get some understanding and clarification on Registration and linking is implemented in Roku.
Am trying to setup Rendezvou style registration. Here is what i understand so far.
1. Preset the registration screen. Call webservice to generate a CODE and present it to user
2. User enters the code on website www.mywebsite.com/roku
3. Take the code, get roku serial number, save it in database and send a sucess flag?

Am trying to understand what the implementation in web services will be.
Can anyone provide me with a walk through on how the linking happens
An example in any language will be helpful.

appreciate it,
thanks.
0 Kudos
1 REPLY 1\
RokuKevin
Level 9

Device Linking Server Side Implementation

The key to registration and linking is to save a "deviceToken" in the registry for your Roku application on the Roku box. This deviceToken is mapped to a user account on your web server, so that when your Roku application send urls with this deviceToken your web server can customize responses according to the user account mapped to that deviceToken.

The regCode in Rendezvou style registration enables the assignment of this deviceToken dynamically so that a factory reset on the Roku box will delete the registry for you application and the deviceToken stored in it. This way a user is assured that no private data is passed on through a factory reset. This protection of private data is the reason Roku does NOT recommend storing Roku box serial numbers on your website.

The Device Registration and Linking guide walks you through an example message flow between your Roku channel app and your web server. The "registration" sdk example shows you an example Roku channel app implementation. The server side implemenation will be unique to your website with the objective of mapping a deviceToken to a user account.

Some example psuedo code for the web server piece:

http://yourserver.com/restfulUrl/preLink
http://yourserver.com/restfulUrl/linkAccount

preLink: (Called by your Roku DVP App)
------------------------------------------

<% deviceID=Request.deviceID;
regCode=CreateUniqueRegCode();

GlobalAssociativeArray[regCode] = "Not Activated";

response='<result>
<status>success</status>
<regCode>'
+regCode+'
</regCode>
<retryInterval> 30 </retryInterval>
<retryDuration> 900</retryDuration>
</result>';

return response;
%>


Activate Form on your website: http://yourserver.com/roku
------------------------------------------

<form> /* on your website you will have a form that creates a mapping from deviceToken to userID */
regcode = request.regcode;

if (GlobalAssociativeArray[regCode] != null && GlobalAssociativeArray[regCode] == "Activated")
{
userid = GetCurrentUserid();
deviceToken = CreateDeviceToken();

GlobalAssociativeArray[deviceToken] = userid;
GlobalAssociativeArray[regCode] = deviceToken;
persistDevicetokenToUserIDRelationInDB();
}
else
{
return BadRegCode;
}
</form>


linkAccount: (Called by a form on your website)
------------------------------------------

<%
deviceID=Request.deviceID;
regCode=Request.regCode;

if (GlobalAssociativeArray[regCode] != "Not Activated")
{
userid = GlobalAssociativeArray[deviceToken];

response='<result>
<status>success</status>
<deviceToken>'
+deviceToken+'
</deviceToken>
<userid>'
+userid+'
</userid>
</result>';
}
else
{
response='<result>
<status>failure:NotActivated</status>'
</result>';
}
return response;
%>
0 Kudos