The registry is sandboxed for each application based on the application's signed id number. I don't know of a way to get or duplicate that id number without installing the specific application.
you would add a second call to validate the registration token somewhere between the "is linked" check and the actual retrieval of the xml files for content population. That's what I do for all my channels anyway and it works just fine.
if the authorization key exists it sends it to the server, the server validates the status, and returns either an "ok", "You must resubscribe", or "you are not authorized". Based on the four possible outcomes (these three + the islinked key) it displays the required screen.
"destruk" wrote:I wish I could rate posts on this board. This would get maximum points if I could! 🙂
My current/revised authentication routine is done in four parts, with sufficient pauses between each check to update what the screen displays based on the token received from the server, as a sort of progress report.
Basically, if the roku device hasn't been linked, then it sends the serial number and a request to the server to get a registration code key number to display on the screen.
The roku displays the key and the URL to go to, while the server stores the serial and registration code that was created into a temporary scratch database table on the server.
The user then goes to their computer, to the url specified, creates a user account on the server, (or uses their existing account), and then goes to the link page on the server and types in the code.
The server checks the temporary table for the code, if it matches one that exists, it logs the user id they are signed in with, the code that was entered, and any metrics we are storing for historical reference, and it sends back a 'Hi there I have been linked to this specific account' secret key number to the roku.
The roku stores this secret key number in the islinked section of the registry.
Next, when it has that key number, it then displays something along the lines of "Please subscribe to this channel to access content - here:" with another url which points to our mega-channel database where the end user can pick and choose what channels they want, what they want to unsubscribe from, enter in special promo codes for 6 months free, 1 month free, a free movie poster mailed out on subscription to their address, etc etc etc
When the app notices a second token being returned to the roku at this point, it checks the value returned from the server. If it matches 'cleared for access', then it stores that as the 'authorization token' for said channel name, and then downloads and displays the content xml's.
With those two keys in the roku registry, when you quit and reenter the channel it first checks for something to be in the linked key - and then it checks the authorization key - if the authorization key exists it sends it to the server, the server validates the status, and returns either an "ok", "You must resubscribe", or "you are not authorized". Based on the four possible outcomes (these three + the islinked key) it displays the required screen.
The serial number isn't supposed to be used for authentication of content, but you can use it for tracking, so that's what my code does for it - it uses it only during the linking process and discards it later, save for logging purposes only.
I'm sure other people do this differently - that's just what made the most sense to me. I also have it storing data in the registry for a 'bookmarks' list for played content, and we have the server tracking and logging every show played, how much was watched, etc etc etc. I find it much easier to work on both sides simultaneously - makes for easier testing.
Actual execution is really fast - if it's linked and cleared, then you enter the channel and nearly immediately are presented with the content lists to play. If you enter and are not linked you get the "Please link your roku" screen, if you enter and have cancelled this channel before, it jumps directly to resubscribe, etc etc. I think it's neat.
Function isLinked() As Dynamic
if Len(m.RegToken) > 0 then
' send RegToken to server for validation
sn = GetDeviceESN()
http = NewHttp(m.UrlValidate)
http.AddParam("deviceID", sn)
http.AddParam("RegToken", m.RegToken)
rsp = http.Http.GetToString()
xml = CreateObject("roXMLElement")
print "GOT: " + rsp
print "Reason: " + http.Http.GetFailureReason()
if not xml.Parse(rsp) then
print "Can't parse getRegistrationCode response"
ShowConnectionFailed()
return ""
endif
if xml.GetName() <> "result"
Dbg("Bad register response: ", xml.GetName())
ShowConnectionFailed()
return ""
endif
if islist(xml.GetBody()) = false then
Dbg("No registration information available")
ShowConnectionFailed()
return ""
endif
'set default value for validate
validate = "fail"
'handle validation of response fields
for each e in xml.GetBody()
if e.GetName() = "validate" then
validate = e.GetBody() 'pass or fail
endif
next
if validate = "" then
Dbg("Parse yields empty validation result")
ShowConnectionFailed()
endif
if validate = "pass" then return true
endif
return false
End Function
Function displayCategoryPosterScreen(category As Object) As Dynamic
if isLinked() then
if validateParam(category, "roAssociativeArray", "displayCategoryPosterScreen") = false return -1
screen = preShowPosterScreen(category.Title, "")
print "attempting to show Poster Screen for " + category.Title
showPosterScreen(screen, category)
return 0
else
return 1
end if
End Function
If your going with a public channel you may want to reconsider this if your saving the serial, unless i am misunderstanding your usage
It's OK to have the SN identified on your website for identification purposes to the user, but it should not be used for authentication.
"joetesta" wrote:
Is this wrong?