I’m trying to get the sample auth linking Roku channel to work. I’ve installed the channel on my Roku stick, set up endpoints for generating and authenticating tokens, but can’t get the disconnect endpoint to work. The Roku Developer Documentation on Authentication and Linking is also useless, as the responses on that page don’t match what I’ve had to actually return from my application.
My code to disconnect looks like this:
sub parseDis(job as object)
result = job.context.context.response
json = parseJSON(result.content)
if json.success = "no"
m.top.disconnect = false
else
m.top.disconnect = true
end if
end sub
So from my application, I’m returning a JSON response that looks like this:
{
"success": "yes"
}
But in the Telnet debug console session I get this output:
Suspending threads...
Thread selected: 2* ...:/components/RegistryTask.xml(55)
Current Function:
052: sec.Write(key, val)
Function RegWrite(key, val, section=invalid)
053: if section = invalid then section = "Default"
054: sec = CreateObject("roRegistrySection", section)
055:* sec.Write(key, val)
056: sec.Flush() 'commit it
057: End Function
Type Mismatch. (runtime error &h18) in pkg:/components/RegistryTask.xml(55)
055: sec.Write(key, val)
Backtrace:
#1 Function regwrite(key As Dynamic, val As Dynamic) As Dynamic
file/line: pkg:/components/RegistryTask.xml(55)
#0 Function go() As Void
file/line: pkg:/components/RegistryTask.xml(35)
Local Variables:
key roString refcnt=3 val:"UNIQUE_ID_HERE3500X"
val Invalid
section String (VT_STR_CONST) val:"Default"
global Interface:ifGlobal
m roAssociativeArray refcnt=3 count:3
sec bsc:roRegistrySection refcnt=1
Threads:
ID Location Source Code
0 pkg:/source/main.brs(15) msg = wait(0, m.port)
1 pkg:/components/SimpleScene.brs(78) oauth_token: invalid
2* ...:/components/RegistryTask.xml(55) sec.Write(key, val)
3[u] ??
*selected [u]unattached(not debuggable)
Any one able to help my decipher as to what’s happening and going wrong?
The immediate reason for the error is this:
key roString refcnt=3 val:"UNIQUE_ID_HERE3500X"
val Invalid
Write()
function takes 2 strings, key and value - and the value in this case is invalid
, no good.
I had a quick look at the sample app and the deeper reason behind is that onDisconnect()
event handler does:
m.regTask.write = {
deviceID: m.rokuDeviceID,
oauth_token: invalid
}
That has to be fixed one way or another. I did not look in more details - e.g. if empty string will do to the logic or better use roRegistrySection.delete()