function init(self) msg.post(".", "acquire_input_focus") if siwg then siwg.set_callback(gpgs_callback) end end function on_message(self, message_id, message, sender) end function on_input(self, action_id, action) if action_id == hash("touch") and action.pressed then if gui.pick_node(gui.get_node("login_btn"), action.x, action.y) then if siwg then print("Login Pressed!") siwg.login() end end if gui.pick_node(gui.get_node("silent_login_btn"), action.x, action.y) then if siwg then print("Login Pressed!") siwg.silent_login() end end end end function gpgs_callback(self, message_id, message) if message_id == siwg.MSG_SIGN_IN or message_id == siwg.MSG_SILENT_SIGN_IN then if message.status == siwg.STATUS_SUCCESS then print("SIWG ID: " .. siwg.get_id()) print("SIWG DisplayName: " .. siwg.get_display_name()) if sys.get_config("siwg.client_id") then print("SIWG id_token: ", siwg.get_id_token()) print("SIWG auth_code: ", siwg.get_server_auth_code()) end elseif message.status == siwg.STATUS_FAILED then print("Status: FAILED") print("Error: " .. message.error) end elseif message_id == siwg.MSG_SIGN_OUT then print("SIWG Logged out!") end print("SIWG is_logged_in: " .. tostring(siwg.is_logged_in())) end