content: sub init()
      m.top.functionName = "request"
      m.utils = CreateObject("roSGNode", "Utils")
  end sub
  
  sub request()
      rsp = {  }
      try
          page = m.top.page.ToStr()
          xfer = CreateObject("roURLTransfer")
          xfer.RetainBodyOnError(true)
          xfer.SetCertificatesFile("common:/certs/ca-bundle.crt")
          xfer.SetRequest("GET")
          if m.global.credentials<>invalid
              youtubeAPI = m.utils.callFunc("getYoutubeAPILocalStorage")
              xfer.AddHeader("Authorization", "Bearer "+FormatJson(m.global.credentials))
              if youtubeAPI<>invalid
                  xfer.AddHeader("clientid", youtubeAPI["client_id"])
                  xfer.AddHeader("clientsecret", youtubeAPI["client_secret"])
              end if
          end if
          xfer.SetURL(m.global.url_server+"history?page="+page)
          
          port = CreateObject("roMessagePort")
          xfer.SetMessagePort(port)
          xfer.AsyncGetToString()
          response = Wait(0, port)
  
          headers = response.GetResponseHeaders()
          body = response.GetString()
  
          rsp = { 
              headers: headers, 
              body: parseJSON(body)
          }
      catch error
          rsp = { "error": error }
      end try
      m.top.response = rsp
  end sub