jellyfin-roku/source/api/userauth.brs

34 lines
835 B
Plaintext
Raw Normal View History

function get_token(user as String, password as String)
bytes = createObject("roByteArray")
bytes.FromAsciiString(password)
digest = createObject("roEVPDigest")
digest.setup("sha1")
hashed_pass = digest.process(bytes)
url = "Users/AuthenticateByName?format=json"
req = APIRequest(url)
json = postJson(req, "Username=" + user + "&Password=" + hashed_pass)
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()
2019-04-20 17:40:06 +00:00
unset_user_setting("token")
2019-03-19 04:17:50 +00:00
unset_setting("active_user")
end function