I have my own library that returns an object of type Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityToken using WIF API. But I want to get token as XML string or XmlElement.
How can I get entire token XML from Saml2SecurityToken object?
You can use the SAML security token handler's WriteToken method. This writes to an XmlWriter. Then convert this to a string.
e.g.;
var sb = new StringBuilder(128);handler.WriteToken(new XmlTextWriter(new StringWriter(sb)), token);