jf-roku/source/api/userauth.brs

46 lines
968 B
Plaintext
Raw Normal View History

function get_token(user as String, password as String)
url = "Users/AuthenticateByName?format=json"
req = APIRequest(url)
2019-04-20 17:54:24 +00:00
json = postJson(req, "Username=" + user + "&Pw=" + password)
if json = invalid then return invalid
2019-04-20 17:40:06 +00:00
userdata = CreateObject("roSGNode", "UserData")
userdata.json = json
userdata.callFunc("setActive")
userdata.callFunc("saveToRegistry")
return userdata
end function
function AboutMe()
2019-04-20 17:40:06 +00:00
id = get_setting("active_user")
url = Substitute("Users/{0}", id)
resp = APIRequest(url)
return getJson(resp)
end function
2019-03-19 04:17:50 +00:00
function SignOut()
if get_setting("active_user") <> invalid
unset_user_setting("token")
end if
2019-03-19 04:17:50 +00:00
unset_setting("active_user")
end function
2019-04-20 17:54:24 +00:00
function AvailableUsers()
users = get_setting("available_users", {})
return users
end function
function PickUser(id as string)
end function
2019-04-20 17:54:24 +00:00
function ServerInfo()
url = "System/Info/Public"
resp = APIRequest(url)
return getJson(resp)
end function