private static OAuth2AccessTokenRequest CreateAccessTokenRequestWithAssertionForSamlSecurityTokens(System.IdentityModel.Tokens.SecurityToken token, Microsoft.IdentityModel.Tokens.SecurityTokenHandlerCollection securityTokenHandlers, string resource) { Utility.VerifyNonNullArgument("securityTokenHandlers", securityTokenHandlers); OAuth2AccessTokenRequest oAuth2AccessTokenRequest = new OAuth2AccessTokenRequest(); if (token is System.IdentityModel.Tokens.SamlSecurityToken) { oAuth2AccessTokenRequest.GrantType = "urn:oasis:names:tc:SAML:1.0:assertion"; } else { oAuth2AccessTokenRequest.GrantType = "urn:oasis:names:tc:SAML:2.0:assertion"; } System.Xml.XmlWriterSettings xmlWriterSettings = new System.Xml.XmlWriterSettings(); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); xmlWriterSettings.OmitXmlDeclaration = true; using (System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create(stringBuilder, xmlWriterSettings)) { securityTokenHandlers.WriteToken(xmlWriter, token); oAuth2AccessTokenRequest.Assertion = stringBuilder.ToString(); } oAuth2AccessTokenRequest.Resource = resource; return(oAuth2AccessTokenRequest); }
public OAuth2WebRequest(string requestUriString, OAuth2AccessTokenRequest request) { _innerRequest = Create(requestUriString); _request = request; }
public OAuth2WebRequest(string requestUriString, OAuth2AccessTokenRequest request) { this._innerRequest = System.Net.WebRequest.Create(requestUriString); this._request = request; }