Forum Discussion

jamilou's avatar
jamilou
Visitor
10 years ago

DeviceUniqueId condition

Hello,

I'm using the videoplayer template and I want to add registration to my channel or some sort of not complicated (to me) restriction.
We'll be a few persons using my channel (4 friends for now will be using my french channel) and I thought of asking them their DeviceUniqueId (if it is possible) to restrict the access to only their rokus and mine.

Do someone have an idea to how to do that ? I thought of something like : If DeviceUniqueId in (rokuFriend1Id,rokuFriend2id, etc..) then give access to channel, else No access

Where can I add this kind of code and what will be the proper way to write it ?
Thank you for your help

Jean-Marie

4 Replies

  • Since you will be making private channel, the mere "access/vanity code" to add it can be the secret shared only with the limited few friends. But, you can also do what you asked in three lines:

    allowed_list = "123456789abc 123456789ab1 123456789ab2 ..."
    serNo = createObject("roDeviceInfo"). GetDeviceUniqueId()
    if inStr(1, allowed_list, serNo) > 0 then ' yes, device is on the approved list

    Now, that's fine for a "toy channel" like this but let me disclaim that hacks like this should not be used for public channels: one, using S/N is discouraged (people sell/gift players, get new ones etc); two, hard-coding it like that is a pain to update the list - have to push new version.
  • "EnTerr" wrote:
    Since you will be making private channel, the mere "access/vanity code" to add it can be the secret shared only with the limited few friends. But, you can also do what you asked in three lines:

    allowed_list = "123456789abc 123456789ab1 123456789ab2 ..."
    serNo = createObject("roDeviceInfo"). GetDeviceUniqueId()
    if inStr(1, allowed_list, serNo) > 0 then ' yes, device is on the approved list

    Now, that's fine for a "toy channel" like this but let me disclaim that hacks like this should not be used for public channels: one, using S/N is discouraged (people sell/gift players, get new ones etc); two, hard-coding it like that is a pain to update the list - have to push new version.


    Hello,
    Thank you for your reply.
    Where do I add this code? (I'm using the VideoPlayer template). Do I have to create a new brs file ? or use it with categoryFeed.brs ?
    If I can use your code with categoryFeed.brs, is this viable :

    allowed_list = "123456789abc 123456789ab1 123456789ab2 ..."
    serNo = createObject("roDeviceInfo"). GetDeviceUniqueId()
    if inStr(1, allowed_list, serNo) > 0 then

    '******************************************************
    ' Set up the category feed connection object
    ' This feed provides details about top level categories
    '******************************************************
    Function InitCategoryFeedConnection() As Object

    conn = CreateObject("roAssociativeArray")

    conn.UrlPrefix = "http://pastebin.com/raw"
    conn.UrlCategoryFeed = conn.UrlPrefix + "/Wed454XXX"

    conn.Timer = CreateObject("roTimespan")

    conn.LoadCategoryFeed = load_category_feed
    conn.GetCategoryNames = get_category_names

    print "created feed connection for " + conn.UrlCategoryFeed
    return conn

    End Function

    else

    Function InitCategoryFeedConnection() As Object

    conn = CreateObject("roAssociativeArray")

    conn.UrlPrefix = "http://pastebin.com/raw"
    conn.UrlCategoryFeed = conn.UrlPrefix + "/blankpage"

    conn.Timer = CreateObject("roTimespan")

    conn.LoadCategoryFeed = load_category_feed
    conn.GetCategoryNames = get_category_names

    print "created feed connection for " + conn.UrlCategoryFeed
    return conn

    End Function


    Thank you very much

    JM
  • Oh boy.
    When i answered, i assumed you already know some on how to develop on Roku. (My apologies, can't teach you in a paragraph how to do that)

    I don't know at all RokuCo's examples - but putting above inside main() seems about right - because that's where everything is started from. Let's say in the beginning - and being absolutely minimalistic, the "if" should change to say "if inStr(1, allowed_list, serNo) < 1 then STOP"
  • "EnTerr" wrote:
    Oh boy.
    When i answered, i assumed you already know some on how to develop on Roku. (My apologies, can't teach you in a paragraph how to do that)

    I don't know at all RokuCo's examples - but putting above inside main() seems about right - because that's where everything is started from. Let's say in the beginning - and being absolutely minimalistic, the "if" should change to say "if inStr(1, allowed_list, serNo) < 1 then STOP"


    Hey thank you for your help, it works !!!!
    I added the condition inside the first function and it opens only if I specify the good Device Id"
    Thank you again