As you can see in the documentation, method OutputToIOStream returns a status and not a stream (first argument - a stream is written to in this method), so you should write:

Set pIOStream = ##Class(%IO.StringStream).%New()
Set tSC = pRequest.OutputToIOStream(pIOStream,..Separators,"",1)
Quit:$$$ISERR(tSC) tSC
Set tSC = mail.AttachStream(pIOStream,..Filename,1,"iso-8859-1")
Quit tSC

Resources property is not evaluated. You can see that in %Installer.Role class, %OnGenerateCode method.

/// Generate code for this document.
Method %OnGenerateCode(pTargetClass As %Dictionary.CompiledClass, pCode As %Stream.TmpCharacter, pDocument As %Installer.Manifest) As %Status [ Internal ]
{
Do pCode.WriteLine(..%Indent()_"Do tInstaller.CreateRole($$$EVAL("_..Target_"),$$$EVAL("_..Description_"),"""_..Resources_""","""_..RolesGranted_""")")
Quit $$$OK
}

You can get around that with this hacky solution:

 <Role
Name="${PMGNAMESPACE}"
Description="Works User Role for ${PMGNAMESPACE} Namespace"
Resources='"_tInstaller.Evaluate("${PMGDbResource}:RW,PMG:RWU")_"' RolesGranted="" />

Which would be compiled into the following code:

 Do tInstaller.CreateRole(tInstaller.Evaluate("${PMGNAMESPACE}"),tInstaller.Evaluate("Works User Role for ${PMGNAMESPACE} Namespace"),""_tInstaller.Evaluate("${PMGDbResource}:RW,PMG:RWU")_"","")

I guess if you need to do that once, it's okay. But if it's a regular occurrence writing a method and calling it from installer might be a better solution.

Here's an article on %Installer usage.

Not sure about delegated authentication (is it only delegated? Or with password? Details may vary depending on your exact setup), but for password authenticated web application SSO is possible by following these steps (originally written for CSP+REST web apps, but the idea is the same):

  1. All brokers effectively have Parameter UseSession = 1;
  2. REST web application and client web application allow only authenticated (i.e. password) access.
  3. REST web application and client web application have reasonable Session timeout (i.e. 900, 3600).
  4. REST web application and client web application have the same GroupById value.
  5. REST web application and client web application have the same cookie path.

If all these conditions are met, user would only consume one license slot per session and perform only one login and audit database would store only one login event per session.