# DeviceUniqueId condition

**URL:** <https://forum.developer.roku.com/t/deviceuniqueid-condition/6714>\
**Category:** Archived\
**Tags:** roku-developer-program\
**Created:** [June 25, 2016, 12:16am UTC](https://forum.developer.roku.com/t/deviceuniqueid-condition/6714 "2016-06-25T00:16:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamilou](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jamilou](https://forum.developer.roku.com/u/jamilou)\
**Post date:** [June 25, 2016, 12:16am UTC](https://forum.developer.roku.com/t/deviceuniqueid-condition/6714/1 "2016-06-25T00:16:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![EnTerr](https://avatars.discourse-cdn.com/v4/letter/e/ba9def/32.png) [@EnTerr](https://forum.developer.roku.com/u/EnTerr)\
**Post date:** [June 25, 2016, 3:31am UTC](https://forum.developer.roku.com/t/deviceuniqueid-condition/6714/2 "2016-06-25T03:31:47Z")

</div>

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:

```auto

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.

---

<div class="post-metadata">

**Author:** ![jamilou](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jamilou](https://forum.developer.roku.com/u/jamilou)\
**Post date:** [June 25, 2016, 1:50pm UTC](https://forum.developer.roku.com/t/deviceuniqueid-condition/6714/3 "2016-06-25T13:50:10Z")

</div>

> “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:
> 
> ```auto
> 
> 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 :

```auto

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

---

<div class="post-metadata">

**Author:** ![EnTerr](https://avatars.discourse-cdn.com/v4/letter/e/ba9def/32.png) [@EnTerr](https://forum.developer.roku.com/u/EnTerr)\
**Post date:** [June 25, 2016, 5:54pm UTC](https://forum.developer.roku.com/t/deviceuniqueid-condition/6714/4 "2016-06-25T17:54:59Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![jamilou](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jamilou](https://forum.developer.roku.com/u/jamilou)\
**Post date:** [June 28, 2016, 3:35am UTC](https://forum.developer.roku.com/t/deviceuniqueid-condition/6714/5 "2016-06-28T03:35:57Z")

</div>

> “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
